我有一个TabActivity
包括 3 tabs
。我设置currentActivity
为1
不是默认的,0
. 当我启动时,我TabActivity
发现 Activity0 也运行,但 Tabactivity 显示了我设置为 Activity1 的界面currentActivity
。此外,当我单击 tab2(包括 Activity2)并再次单击 tba1 或 tab0 时,它们不会再次运行。正如我认为 TabActivity 只是让运行一次。每当我单击选项卡时,我想重新启动选项卡中的每个活动。而且我想跟踪这些,以便在单击后退按钮时应该可以跟踪。
public class ActivityInTab extends TabActivity implements OnTabChangeListener{
TabHost tabHost;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activityintab);
tabHost = getTabHost();
TabSpec meSpec = tabHost.newTabSpec("Ben");
meSpec.setIndicator("Ben", getResources().getDrawable(R.drawable.icon_me));
Intent meIntent = new Intent(this, MeActivity.class);
meSpec.setContent(meIntent);
TabSpec searchSpec = tabHost.newTabSpec("Arama");
searchSpec.setIndicator("Çevrende Ara", getResources().getDrawable(R.drawable.icon_search));
// Intent searchIntent = new Intent(this, SearchActivity.class);
// searchSpec.setContent(searchIntent);
TabSpec resultSpec = tabHost.newTabSpec("Aradıklarım");
resultSpec.setIndicator("Arama Sonuçlarım", getResources().getDrawable(R.drawable.icon_result));
// Intent resultIntent = new Intent(this, ResultActivity.class);
// resultSpec.setContent(resultIntent);
tabHost.addTab(searchSpec);
tabHost.addTab(meSpec);
tabHost.addTab(resultSpec);
tabHost.setCurrentTab(1);
tabHost.setOnTabChangedListener(this);
}
@Override
public void onTabChanged(String tabId) {
if(tabId.equals("Ben") && tabHost.getCurrentTab()==0){
MeActivity meact = (MeActivity) getLocalActivityManager().getActivity(tabId);
}
if(tabId.equals("Arama") && tabHost.getCurrentTab()==1){
SearchActivity sact= (SearchActivity) getLocalActivityManager().getActivity(tabId);
}
if(tabId.equals("Aradıklarım") && tabHost.getCurrentTab()==2){
ResultActivity ract = (ResultActivity) getLocalActivityManager().getActivity(tabId);
}
}
}