listview - Android PopupMenu opening on wrong positions -
i have listview each item has button opens popupmenu options.
most of time, these menus open @ wrong positions (sometimes open on correct positions), these random opens not consistent.
choosing option in menu manipulate correct item on position tried open menu
my code:
settings.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { popupmenu popup = new popupmenu(context, settings); popup.getmenuinflater().inflate(r.menu.notes_menu, popup.getmenu()); popup.setonmenuitemclicklistener(new popupmenu.onmenuitemclicklistener() { public boolean onmenuitemclick(menuitem item) { string itemtitle = item.gettitle().tostring(); switch (itemtitle) { case "add pictures": //adding pictures case "delete": //deleting case "share": //sharing } return true; } }); popup.show(); } });
this settings
button located inside public view getview(final int position, view convertview, viewgroup parent)
method of listview adapter.
any appreciated! ^^
create popup before setting onclicklistener , call popup.show() inside onclick().
Comments
Post a Comment