Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Android Material Design Popup Menu
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.item1_id) {
Toast.makeText(getApplicationContext(), "Item 1 is selected", Toast.LENGTH_SHORT).show();
} else if (id == R.id.item2_id) {
Toast.makeText(getApplicationContext(), "Item 2 is selected", Toast.LENGTH_SHORT).show();
} else if (id == R.id.item3_id) {
Toast.makeText(getApplicationContext(), "Item 3 is selected", Toast.LENGTH_SHORT).show();
}
return super.onOptionsItemSelected(item);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment