I am working on an android project where I am using a ListView and allowing the user to long press on the item so that they can select multiple items within the list view. This bit is working properly, but the problem that I am having is finding out which item has been selected so that I can get the value out and perform a query on the database based on what the user has selected. Below is the code that I am using for the the checked state event but I can’t figure out from here how to get the value from the TextView.
public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked)
{
final int checkedCount = getListView().getCheckedItemCount();
String data =
switch (checkedCount)
{
case 0:
mode.setSubtitle(null);
break;
case 1:
mode.setSubtitle("One item selected");
break;
default:
mode.setSubtitle("" + checkedCount + " items selected");
break;
}
}
Thanks for any help you can provide.
not sure why you are looking to take the value from TextView. As it is non-editable so you have positron of the item, just get the data from adapter at this position and you will get what yo set in the Text View at this position.