我遇到了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");
}
}