Reputation: 5840
I have this code for showing a Menu:
public boolean onCreateOptionsMenu(Menu menu) {
this.menu = menu;
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.options_menu, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.Email_settings:
// startActivity(new Intent(this, About.class));
return true;
case R.id.Help_settings:
// startActivity(new Intent(this, Help.class));
return true;
default:
return super.onOptionsItemSelected(item);
}
}
The code works fine when pressing the device options button.
How can i open the menu on a button click from inside my screen and not the device options button?
Upvotes: 0
Views: 332
Reputation: 1662
Use Activity.openOptionsMenu() method.
Be sure to use this method only after options menu is instanciated(onCreateOptionsMenu was already executed)
Upvotes: 1