简体   繁体   中英

when does onCreateOptionsMenu get called when activity is in tab?

I have a tabHost and adding activity to the tab.

Intent myIntent = new Intent(this, MyActivity.class);
mySpec.setContent(myIntent);

but MyActivity's onCreateOptionsMenu doesn't get called.

How do I add item to actionBar when my activity is in a tab?

I want to add different items to actionBar in different tabs(activities)

Since the introduction of the ActionBar the tab API has changed a lot. Tabhosts are now deprecated Tabs inside a Tabhost will not affect the actionbar.

I would recommend to completely abandon TabHosts and use the ActionBarSherlock to get a native ActionBar on Devices beyond Android 3.2

In this way you get better looking tabs on all devices and the menu is correctly displayed on Phones with Android 4.x

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM