0

How to make this kind of menu for recycleview Item . This is mainly a drop down menu to do action for that particulate item.

enter image description here

Bajirao Shinde
  • 1,356
  • 1
  • 18
  • 26
Zahidul Islam
  • 3,180
  • 1
  • 25
  • 35

1 Answers1

2

Use the three dot menu view as ImageView in your RecyclerView Item. onClick of that ImageView open the popup menu.

sample code is here.

view.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {
    final PopupMenu popupMenu = new PopupMenu(context, v);
    final Menu menu = popupMenu.getMenu();

    popupMenu.getMenuInflater().inflate(R.menu.menu_item_action, menu);
    popupMenu.setOnMenuItemClickListener(onMenuItemClickListener);

    switch (Global.listMode) {
      case Global.LIST_STYLE_NORMAL: {
        menu.findItem(R.id.action_delete).setVisible(false);
        break;
      }
      case Global.LIST_STYLE_FAVORITE: {
        menu.findItem(R.id.action_add_to_favorite).setVisible(false);
        break;
      }
      case Global.LIST_STYLE_WATCH_LIST: {
        menu.findItem(R.id.action_add_to_watch_list).setVisible(false);
        break;
      }
      case Global.LIST_STYLE_DOWNLOAD: {
        menu.findItem(R.id.action_download).setVisible(false);
        break;
      }
    }

    itemPosition = (int) view.getTag(R.id.tag_item_position);
    popupMenu.show();
  }
});
Maheshwar Ligade
  • 6,709
  • 4
  • 42
  • 59