I have Listview. And I want to add overflow menu to each listview's item. How to do it? Now I add button to every item and show dropdown menu when user clicks on this button. But I want to replace this ordinary button with overflow one.
Asked
Active
Viewed 1,012 times
1 Answers
1
- Add an ImageView or Button to trigger the menu on the right of your listview items. To get the "overflow" icon, see this question: How do I get a copy of the Android overflow menu icon?
- Add an onClickListener to your ImageView or Button
On your onCreate() method, create a popup menu like this:
popupMenu = new PopupMenu(this, findViewById(R.id.anchor)); popupMenu.getMenu().add(...); popupMenu.setOnMenuItemClickListener(this);
In your onClickListener trigger the display of the popup menu
popupMenu.show();

Community
- 1
- 1

Quanturium
- 5,698
- 2
- 30
- 36