Reputation: 34036
hello i would like to present a different menu in my activity depending on some condition. i tried like this.
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater inflater = getMenuInflater();
if (specialMode)
{
inflater.inflate(R.menu.menuA, menu);
}
else
{
inflater.inflate(R.menu.menuB, menu);
}
return true;
}
however, i always get the same menu, no matter what the value of specialMode is.
Upvotes: 1
Views: 552
Reputation: 8935
onCreateOptionsMenu is called only once ( upon first creation), try using onPrepareOptionsMenu method it get called every time menu is shown.
Upvotes: 4