Each Tab
in the TabHost
has a number starting from 0, so you have to know which tab you are in now by using int currentTab = th.getCurrentTab();
and then clear the previous menu by using menu.clear()
then adding your new menu by using inflater.inflater(menuID, menu)
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
MenuInflater inflater = getMenuInflater();
int currentTab = th.getCurrentTab();
Toast.makeText(getApplicationContext(), currentTab+"", Toast.LENGTH_SHORT);
if (currentTab == 0){
menu.clear();
inflater.inflate(R.menu.first, menu);}
else{
menu.clear();
inflater.inflate(R.menu.second, menu);}
return super.onPrepareOptionsMenu(menu);
}
note:
onCreateOptionsMenu
will not help you in your case