I have the below code and I can't understand why my code doesn't show up menu. If the activity containing data, condition_true = true
otherwise condition_true = false
. I can clearly see the control going to menutag and the condition is true too. Even I am getting Inflated
string too in log. But still menu doesn't show up. I have seen lot of posts on these like link 1, link2 etc., but that didn't solve my problem. Can someone please help me on this issue?
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
menu.clear(); //Clear view of previous menu
MenuInflater inflater = getSupportMenuInflater();
Log.d("menutag", condition_true);
if(condition_true)
{
inflater.inflate(R.layout.menu, menu);
Log.d("menutag","Inflated");
}
return super.onPrepareOptionsMenu(menu); // replaced this with true, but no use.
}