Combining Menu And Tab
I am using this 'Tab layout and Listview' from http://www.androidhive.info/2012/05/android-combining-tab-layout-and-list-view/ and 'Android Menus' from http://www.androidhive.info/
Solution 1:
Here:
publicbooleanonCreateOptionsMenu(Menu menu)
{
MenuInflatermenuInflater= getMenuInflater();
menuInflater.inflate(R.layout.menu, menu);
returntrue;
}
you pass R.layout.menu
to MenuInflater.inflate(..)
method, but it should be R.menu.menu
. Move your menu.xml
file from res/layout
dir to res/menu
dir.
Solution 2:
I ran into similar problem with TabHost. By default, Android creates an options menu for the parent activity, i.e. TabHost in your case. The child tab does not receive the OnCreateOptionsMenu
event. Therefore, your menu is not being created.
Put the option menu creation/handling code in the activity extending TabActivity. You can change the preference menu content by checking which tab is currently selected by checking getTabHost.getCurrentTab
or getTabHost.getCurrentTabTag
and inflating appropriate menu.
Post a Comment for "Combining Menu And Tab"