Android 选项卡栏中的活动组问题
在我的应用程序中,我已将tabbar与活动组一起使用。我有四个标签,像家,股票,现金,文章。在我的应用程序中,首先从主页显示主页用户在webview中单击,它将转到homepage1活动。从主页1“活动”用户单击“库存”选项卡,它将转到“库存”活动。从“库存活动”用户单击“主页”选项卡,它将转到主页1活动。我想展示家里的活动,谁能告诉我怎么做 我的问题是使用活动组在选项卡之间切换,它将显示最后一个活动。我想显示第一个活动 好的,我会附上我的代码Android 选项卡栏中的活动组问题,android,tabbar,activitygroup,Android,Tabbar,Activitygroup,在我的应用程序中,我已将tabbar与活动组一起使用。我有四个标签,像家,股票,现金,文章。在我的应用程序中,首先从主页显示主页用户在webview中单击,它将转到homepage1活动。从主页1“活动”用户单击“库存”选项卡,它将转到“库存”活动。从“库存活动”用户单击“主页”选项卡,它将转到主页1活动。我想展示家里的活动,谁能告诉我怎么做 我的问题是使用活动组在选项卡之间切换,它将显示最后一个活动。我想显示第一个活动 好的,我会附上我的代码 spec = tabHost.newTabSpec
spec = tabHost.newTabSpec("FirstGroup").setIndicator("FirstGroup",
getWallpaper()).setContent( new Intent(this,FirstGroup.class));
tabHost.addTab(spec);
视图视图=
getLocalActivityManager().startActivity(“CitiesActivity”,
新的
Intent(这是CitiesActivity.class)。addFlags(Intent.FLAG\u ACTIVITY\u CLEAR\u WHEN\u TASK\u RESET
)).getDecorView()
运行此示例
在活动和选项卡之间切换
我已经发布在pastebin,我的链接是
您好,您是否尝试了如下所示的tabchanged事件
tabHost.addTab(tabHost.newTabSpec("tab1").setContent(
R.id.content_movies).setIndicator("",
getResources().getDrawable(R.drawable.icon)));
tabHost.addTab(tabHost.newTabSpec("tab2").setContent(
new Intent(this, Sample.class)).setIndicator("",
getResources().getDrawable(R.drawable.menu_icon)));
tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
@Override
public void onTabChanged(String arg0) {
if(arg0.equals("tab1"))
{
/*write the code here to show the view
Currentclass, the class where you have used ontabchanged function and
Newclass is the class where you want to navigate*/
Intent obj_intent = new Intent(CureentClass.this,Newclass.class);
startActivity(obj_intent);
}
else if (arg0.equals("tab2")) {
// write the code here to show the view
}
//similarly for other tabs
});
@user426344:你面临什么问题,告诉我朋友?@user426344:参考代码,我已经编辑并传达了你面临的什么问题?你可以查看链接吗?我在decorview()中实现了以前的活动将被存储。您的代码将调用新的活动,而不使用Tabbar查看上面的代码并检查此链接@user@Sankar当我们都被这里的爱和支持所淹没时,我想提醒你们这是StackOverflow,而不是PastebinOverflow,您拒绝其他用户使用工作解决方案搜索类似问题的答案@Sankar请编辑您的答案,并将您在pastebin中删除的代码包括在内。此外,对于所有发表这些评论的人,我希望这能满足你们的担忧。
tabHost.addTab(tabHost.newTabSpec("tab1").setContent(
R.id.content_movies).setIndicator("",
getResources().getDrawable(R.drawable.icon)));
tabHost.addTab(tabHost.newTabSpec("tab2").setContent(
new Intent(this, Sample.class)).setIndicator("",
getResources().getDrawable(R.drawable.menu_icon)));
tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
@Override
public void onTabChanged(String arg0) {
if(arg0.equals("tab1"))
{
/*write the code here to show the view
Currentclass, the class where you have used ontabchanged function and
Newclass is the class where you want to navigate*/
Intent obj_intent = new Intent(CureentClass.this,Newclass.class);
startActivity(obj_intent);
}
else if (arg0.equals("tab2")) {
// write the code here to show the view
}
//similarly for other tabs
});