i would like to implement a popup menu similar to google\'s play store as shown below.
Using popup menu it's quite simple to create a menu with these three steps:
1 - Add a click listener to the menu button using OnClickListener or as i prefer from the layout xml:
2 - Create the menu layout menu_layout.xml:
3 - Create a popup menu, inflate the xml layout and show it:
public void showMenu (View view)
{
PopupMenu menu = new PopupMenu (this, view);
menu.setOnMenuItemClickListener (new PopupMenu.OnMenuItemClickListener ()
{
@Override
public boolean onMenuItemClick (MenuItem item)
{
int id = item.getItemId();
switch (id)
{
case R.id.item_settings: Log.i (Tag, "settings"); break;
case R.id.item_about: Log.i (Tag, "about"); break;
}
return true;
}
});
menu.inflate (R.menu.menu_layout);
menu.show();
}