안드로이드에서 tablayout 중 하나의 탭에서 사실 (또는 전화)로 (부울) onWindowFocusChanged 방법을 ..하는 방법안드로이드에서 tablayout의 한 탭에서 onWindowFocusChanged (boolean) 메서드를 true (또는 호출)로 만드는 방법은 무엇입니까?
설명 : tablayout에서
가 자동으로 기본 활동 (참)라고() onWindowFocusChanged, 그러나 다음 탭 (다른 활동을 호출)을 클릭/터치하면 은 onWindowFocusChanged()를 호출 할 수 없습니다 !!!!!! 두 번째 탭에서 onWindowFocusChanged()를 호출하는 방법?
소스 코드 :
TabTwo 활동이 솔루션을주지하시기 바랍니다 실행되는 동안public class TabTestActivity extends TabActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources();
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, TabOne.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("TabOne").setIndicator("TabOne",
res.getDrawable(R.drawable.ic_tab_One))
.setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs
intent = new Intent().setClass(this, TabTwo.class);
spec = tabHost.newTabSpec("TabTwo").setIndicator("TabTwo",
res.getDrawable(R.drawable.ic_tab_az))
.setContent(intent);
tabHost.addTab(spec);
//tabHost.setCurrentTab(2);
}
public void onWindowFocusChanged(boolean hasFocus) {
// TODO Auto-generated method stub
Toast.makeText(this, ""+hasFocus , Toast.LENGTH_LONG).show();
super.onWindowFocusChanged(hasFocus);
}
}
-----------------------------------------------------------------------------------------------------
public class TabOne extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView textview = new TextView(this);
textview.setText("This is the Coll tab");
setContentView(textview);
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
// TODO Auto-generated method stub
Toast.makeText(this, "On window One"+hasFocus , Toast.LENGTH_LONG).show();
super.onWindowFocusChanged(hasFocus);
}
}
--------------------------------------------------------------------------
public class TabTwo extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView textview = new TextView(this);
textview.setText("This is the Coll tab");
setContentView(textview);
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
// TODO Auto-generated method stub
Toast.makeText(this, "On window TabTwo"+hasFocus , Toast.LENGTH_LONG).show();
super.onWindowFocusChanged(hasFocus);
}
}
TabTwo의 (2ndTab)가 호출되지 onWindowFocusChanged. tabHost.setFocusable (true);를 제공하려고했습니다. 나는 일하지 않는다 !!!
은 TabOne의 onWindowFocused라고합니다? –
@ sadeshKumar : 예, TabOnes onWindowFocused를 호출합니다 !!! –