I have a ListView , I need to select an item in it and, when I click on a menu item, do actions. In this case, everything should be beautiful (so I chose the context menu, rather than dialog activity, as before) and the handler should get the position of the clicked item.
I came to the option to handle a long click on the listener with setOnItemLongClickListener , and in the onItemLongClick method onItemLongClick call a context menu to which I can transfer the position of the clicked item. But I ran into the problem that when the button is clicked, the context menu is called - no! The easiest option was to create a button (programmatically, without a layout file) and click on it. Initially, I wanted to call the onCreateContextMenu method, but there were a lot of arguments and I just don’t know where they come from, or how to manage them or how to replace them.
So, what is the question: how to programmatically make a long press on the button to bring up the context menu?
Не люблю я такую бяку делать, но без нее никак :)).
onCreateContextMenureceives only three parameters, each of which is perfectly documented. Also, it does not need to be called up from somewhere - it will be called up with a long tap on the item. - pavlofff