简体   繁体   中英

How to create context menu from the list which contain multi line

I have some question, If I create listview like this

[text]

[text]


[text]

[text]


each list contain 2 lines and I want to make context menu when I try long press to each list it will show context menu

So how to create context menu from the list which contain multi line....

Are you registering the ListView for the context menu using

registerForContextMenu(listView);

or are you creating your own context menu using listView.setOnItemLongClickListener(onItemSelctedListener()) ?

In both cases, there shouldn't be a problem because they act reacting to each element of the ListView

However, if you are using

listView.setOnLongClickListener(onLongClickListener)

then you are registering it to the whole list, and it doesn't matter where you press in the list, its going to bring the same context menu.

I hope that helps you with something.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM