TabHost 内的 ActivityGroup 首次运行后不显示内容
我对 ActivityGroup 有疑问。我的应用程序有 4 个选项卡,其中 2 个具有 ActivityGroup 和另外 2 个简单的活动。问题是,首次运行应用程序内容后正确显示,并且当通过后退按钮离开应用程序并返回时,具有活动组的选项卡不显示任何内容,包括菜单。而具有简单活动的选项卡可以正常工作。 你有什么想法吗?
好的,某种代码) 设置此选项卡:
private TabSpec getFrontPageTab() {
Intent intent = new Intent(context, ActivityGroupHome.class);
return tabHost
.newTabSpec("home")
.setIndicator(
getTabView(R.drawable.tabbar_home, "str_home"))
.setContent(intent);
}
ActivityGroupHome:
public class ActivityGroupHome extends ActivityGroupBase {
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
ActivityUtils activityUtils = ActivityUtils.getInstance(this);
activityUtils.addActivityGroup("Home", this);
activityUtils.startHomeActivity("Home");
}
}
来自 ActivityUtils 的方法:
public void startHomeActivity(String activityGroupName) {
if (activityGroupName != null) {
startHomeActivityForActivityGroup(activityGroupName);
} else {
Intent intent = new Intent(context, AsyncMainActivity.class);
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(intent);
}
}
private void startHomeActivityForActivityGroup(String activityGroupName) {
ActivityGroupListItem activityGroupItem = activityGroups
.findGroupByName(activityGroupName);
if (activityGroupItem != null) {
Intent intent = new Intent(activityGroupItem.activityGroup,
AsyncMainActivity.class);
intent.putExtra(ACTIVITY_GROUP_NAME, activityGroupItem.name);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
View view = activityGroupItem.activityGroup
.getLocalActivityManager().startActivity("Home", intent)
.getDecorView();
activityGroupItem.activityGroup.setContentView(view);
activityGroupItem.stack.add("Home");
}
}
I have issue with ActivityGroup. My app has 4 tabs, 2 of which has ActivityGroup and 2 more simple activity. The problem is that after first run of app content is shown properly, and when leave app through back button and return, tabs with activity group dont shown any content, including menus. While tabs with simple activity work properly.
D'you have any ideas?
Ok, some sort of code)
Setting this tab:
private TabSpec getFrontPageTab() {
Intent intent = new Intent(context, ActivityGroupHome.class);
return tabHost
.newTabSpec("home")
.setIndicator(
getTabView(R.drawable.tabbar_home, "str_home"))
.setContent(intent);
}
ActivityGroupHome:
public class ActivityGroupHome extends ActivityGroupBase {
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
ActivityUtils activityUtils = ActivityUtils.getInstance(this);
activityUtils.addActivityGroup("Home", this);
activityUtils.startHomeActivity("Home");
}
}
Methods from ActivityUtils:
public void startHomeActivity(String activityGroupName) {
if (activityGroupName != null) {
startHomeActivityForActivityGroup(activityGroupName);
} else {
Intent intent = new Intent(context, AsyncMainActivity.class);
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(intent);
}
}
private void startHomeActivityForActivityGroup(String activityGroupName) {
ActivityGroupListItem activityGroupItem = activityGroups
.findGroupByName(activityGroupName);
if (activityGroupItem != null) {
Intent intent = new Intent(activityGroupItem.activityGroup,
AsyncMainActivity.class);
intent.putExtra(ACTIVITY_GROUP_NAME, activityGroupItem.name);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
View view = activityGroupItem.activityGroup
.getLocalActivityManager().startActivity("Home", intent)
.getDecorView();
activityGroupItem.activityGroup.setContentView(view);
activityGroupItem.stack.add("Home");
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论