Grabbing The List Item Textview Value When Contextmenu Is Opened
On a ListView single/short click, I can do this: protected void onListItemClick(ListView listView, View v, int position, long id) { tvInt = reviews.get(position); } Ho
Solution 1:
The MenuItem
packs extra information from where you could extract the position
of the clicked row in the ListView
and then simply use the code you used in the onListItemClick
callback:
@OverridepublicbooleanonContextItemSelected(MenuItem item) {
AdapterView.AdapterContextMenuInfoinfo= (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
intclickedPosition= info.position;
tvInt = reviews.get(position);
// ...
The same information, ContextMenuInfo
, is available in the onCreateContextMenu
callback if you want to get the String when building the ContextMenu
.
Post a Comment for "Grabbing The List Item Textview Value When Contextmenu Is Opened"