Overflow menu for list items

The overflow action menu looks exactly as I need it, but it seems to work only in action bars. However, I would like to use this three-point menu on the right side of each list item.

Action Overflow Menu Outside Action Bar

Is there a built-in view that can be used for this?

+5
source share
1 answer

You can use ImageView and PopupMenu .

 Context context = ... ImageView overflow = ... PopupMenu popup = new PopupMenu(context, overflow); popup.inflate(R.menu.your_menu_resource); popup.setOnMenuItemClickListener(...); overflow.setOnClickListener(new View.OnClickListener() { @Override public final void onClick(View v) { popup.show(); } } overflow.setOnTouchListener(popup.getDragToOpenListener()); 
+4
source

Source: https://habr.com/ru/post/1237981/


All Articles