在android中单击任何选项卡时启动主活动
我有三个包含子活动的选项卡,问题是当我单击其中任何一个选项卡时,它都不会显示主活动。我如何在这三个选项卡栏中显示主活动…有人对此有解决方案吗 提前。。 :) Tabmain TabActivity在android中单击任何选项卡时启动主活动,android,Android,我有三个包含子活动的选项卡,问题是当我单击其中任何一个选项卡时,它都不会显示主活动。我如何在这三个选项卡栏中显示主活动…有人对此有解决方案吗 提前。。 :) Tabmain TabActivity TabHost tabHost = getTabHost(); TabSpec HomeSpec = tabHost.newTabSpec("Home"); HomeSpec.setIndicator("Home", getResources().getDrawable(R.d
TabHost tabHost = getTabHost();
TabSpec HomeSpec = tabHost.newTabSpec("Home");
HomeSpec.setIndicator("Home", getResources().getDrawable(R.drawable.home));
Intent HomeIntent = new Intent(this, HomeMediator.class);
HomeSpec.setContent(HomeIntent);
TabSpec SearchSpec = tabHost.newTabSpec("Search");
SearchSpec.setIndicator("Search", getResources().getDrawable(R.drawable.search));
Intent songsIntent = new Intent(this, SearchMediator.class);
SearchSpec.setContent(songsIntent);
TabSpec TreeInfoSpac = tabHost.newTabSpec("Tree Info");
TreeInfoSpac.setIndicator("Botanical Name", getResources().getDrawable(R.drawable.carrot));
Intent videosIntent = new Intent(this, BotaniacalMediator.class);
TreeInfoSpac.setContent(videosIntent);
tabHost.addTab(HomeSpec);
tabHost.addTab(SearchSpec);
tabHost.addTab(TreeInfoSpac);
tabHost.setOnTabChangedListener(new OnTabChangeListener() {
@Override
public void onTabChanged(String tabId) {
// TODO Auto-generated method stub
}
});
禁忌群体活动
private ArrayList<String> mIdList;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (mIdList == null) {
mIdList = new ArrayList<String>();
}
}
public void finishFromChild(Activity child) {
LocalActivityManager manager = getLocalActivityManager();
int index = mIdList.size() - 1;
if (index < 0) {
finish();
return;
}
manager.destroyActivity(mIdList.get(index), true);
Log.i("Activity Finish:", manager.getCurrentId());
mIdList.remove(index);
index--;
String lastId = mIdList.get(index);
Intent lastIntent = manager.getActivity(lastId).getIntent();
Window newWindow = manager.startActivity(lastId, lastIntent);
setContentView(newWindow.getDecorView());
}
public void startChildActivity(String Id, Intent intent) {
Window window = getLocalActivityManager().startActivity(Id,
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
if (window != null) {
mIdList.add(Id);
setContentView(window.getDecorView());
Log.i("Activity Start:", getLocalActivityManager().getCurrentId());
}
}
家
我不太清楚你的意思,但要使用
OnTabListener
启动意图
Intent main = new Intent (yourclass.this, MainClass.class);
startActivity(main);
您可以在第一个tabspec中进行设置,如下所示
Intent HomeIntent = new Intent(this, MainClass.class);
HomeSpec.setContent(HomeIntent);
请提供您正在使用的代码qtn有点模糊
Intent main = new Intent (yourclass.this, MainClass.class);
startActivity(main);
Intent HomeIntent = new Intent(this, MainClass.class);
HomeSpec.setContent(HomeIntent);