artem
artem

Reputation: 16777

ContextMenu onItemClick (ListView)

I need a context menu to be shown when user clicks on item in listview (not long tap). How it can be implemented?

Upvotes: 2

Views: 1609

Answers (2)

Tosa
Tosa

Reputation: 658

Easiest way it probably to do it like Reflog said.

But you could try it like this:

  1. enable long click though and you need to call registerForContextMenu(list) for the list.
  2. call the performLongClick() in the OnItemClickListener
  3. override the onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) function, there just add the menu items by menu.add().

Hope this helps.

Upvotes: 2

reflog
reflog

Reputation: 7645

use AlertDialog.Builder with 'options' parameter. It emulates the context menu.

Upvotes: 1

Related Questions