androidactivitygroup

How to add menu?


I use group for tabhost. In MyGroup, below code to call AActivity:

Intent intent = new Intent(this, AActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);  
Window w = NASGroup.group.getLocalActivityManager().startActivity("AActivity", intent);  
View view = w.getDecorView();
MyGroup.group.setContentView(view);

Show AActivity and menu button works. Then, I try use AActivity to call BActivity as below code:

Intent intent = new Intent(AActivity.this, BActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);  
Window w = NASGroup.group.getLocalActivityManager().startActivity("BActivity", intent);  
View view = w.getDecorView();
MyGroup.group.setContentView(view);

BActivity show, but the menu button does not work without any error message. I also try call BActivity by MyGroup as below code:

Intent intent = new Intent(this, BActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);  
Window w = NASGroup.group.getLocalActivityManager().startActivity("BAActivity", intent);  
View view = w.getDecorView();
MyGroup.group.setContentView(view);

BActivity show, and menu button works. If I still want to call BActivity by AActivity. How can I do?


Solution

  • Instead of adding separate menus in your child activity classes, add all the menus together in your parent class which extends ActivityGroup. and implement OnTabChangeListener to detect the chosen activity tab and alter (show/hide) your menus accordingly