android - ContextMenu not popping up on Long click -


The context menu is not popping context menu on long click in the list list. I have extended the base adapter and used a visual holder to apply custom view with textviews and an image button.

  adapters = new MyClickableListAdapter (this, R.LetTimeLine , MOBJject); List.setAdapter (adapter); RegisterForContextMenu (list);  

implementation of onCreateContextMenu

  @Override Public Zero onCreateContextMenu (ContextMenu Menu, Visual V, ContextMenuInfo menuInfo) {// TODO Auto-built method Stub Super. OnCreateContextMenu (Menu, V, MenuEnfo); Log D. (Tag, "entering the context menu"); Menu.setHeaderTitle ("context menu"); Menu.add (Menu.NONE, DELETE_ID, Menu.NONE, "Delete") .setIcon (R.drawable.icon); }  

The XML for the list view is here

  & lt; ListView Android: id = "@ + id / list" Android: layout_width = "fill_parent" android: layout_heat = "wrap-content" />  

I've been trying it for so many days. I think it is impossible to register the reference menu for a custom list view like this. Correct me if I'm wrong (probably the sample code with).

Now I'm thinking of adding a button to the list item and it displays a menu when clicked. Is it possible to use dialogue in a few other ways?

Any help would be appreciated ..

why not use you ListActivity

I have in my ListActivity:

  @Override protected void onCreate (savedInstanceState) {/ * setContentView () and all Goods that are in this method * / registerForContextMenu (getListView ()); } @Override Public Zero onCreateContextMenu (ContextMenu Menu, View V, ContextMenuInfo menuInfo) {super.onCreateContextMenu (Menu, V, menuInfo); Adapterview Adapter contactmainfo info; Try {info = (Adapterview Adapter Contains MenuInfo) MenuInfo; } Hold (Class Class Expansion E) {Log. A (Tag, "Bad Menu Infos", E); Return; } Something = (Subway) getListAdapter () GetItem (info.position); Menu.setHeaderTitle (something.getName ()); Menu.setHeaderIcon (something.getIcon ()); Menu.add (0, CONTEXT_MENU_SHARE, 0, "do something!"); } @Override Public Boolean onMenuItemSelected (integer featureId, MenuItem item) {AdapterView.AdapterContextMenuInfo information; Try {info = (adapterview.adaptercontact menuinfo) item.getMenuInfo (); } Hold (Class Class Expansion E) {Log. A (Tag, "Bad Menu Infos", E); return false; } Switch (item.getItemId ()) {case DO_SOMETHING:. / * Id * / something something = getListAdapter () Do sothing with GetItem (info.position); Back true; }  

Comments