android - Is it possible to show context menu at position of item in listview? -


i have listview. want click item , show context menu @ click item position. currently, using below code show context menu , perform action when click item. works context menu position automatic setting @ center of screen. how can fix it?

public class manageactivity extends activity {   private listview mainlistview ;   public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.list_main);         // find listview resource.      mainlistview = (listview) findviewbyid( r.id.mainlistview );     mainlistview.setadapter( listadapter );          registerforcontextmenu(mainlistview);  }   @override   public void oncreatecontextmenu(contextmenu menu, view v, contextmenuinfo menuinfo){       menu.add(0, v.getid(), 0, "edit");       menu.add(0, v.getid(), 0, "delete");   }   @override   public boolean oncontextitemselected(menuitem item){      adapterview.adaptercontextmenuinfo acm = (adaptercontextmenuinfo) item.getmenuinfo();      string  audio_file_name = (string) mainlistview.getitematposition(acm.position);       if(item.gettitle()=="edit")         toast.maketext(getapplicationcontext(), "edit clicked", toast.length_long).show();      if(item.gettitle()=="delete")           toast.maketext(getapplicationcontext(), "delete clicked", toast.length_long).show();     return true; } 

the answer yes. perfect example gridview items in google play app. basically, can find more details here:

android - popup menu when list item view pressed?


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -