I’ve a ListView, builded.
The listView as a row layour with the fiels _id, name, other from SQLite via a simpleCutomAdapter
I’ve an activity to create rows on db, and the list activity is working wel..
Now I want to add a context menu to delete a spceific row.
I’ve succesfully created a context menu with one entry (delete).
I know that when user long-tap on a row, Android triggers
onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
My answer is: what’s the best strategy to read the id from the listview row long-tapped and then keep ‘in mind’ to delete it from db when/if user tap ‘delete’ ?
I know how to delete a row from db, no problem on it. My question is all about how to read the id from a text view of the longtapped row of a listview.
I’m starting right now programming so I prefer doesn’t implement a custom adapter just now.
I’m looking to some things to just retrieve the info…
An idea: the list is build via a simplecustomadapter… is there a way to using the ‘v’ variable to access to the data row and read the id ? (like … v.cursorLine.data._id … 🙂
thanks
Just use:
or in example:
I hope that’s what ware you looking for.
You can assign a TAG to a TextView and then get it in a string.