I am using multi choice mode to select the items in the listview with filter. After searching through the list view when I select an item it highlights a different position instead of the original position of the item in the list view.
For example:
1. With filter, I’ve selected the following item:
2. On the main list view with no filter, it does not highlight the selected item, but the wrong one:
In the below code of my Main Activity, how can I achieve what I’m looking for:
For example:
1. With filter, I’ve selected the following item:
2. On the main list view with no filter, it does not highlight the selected item, but the wrong one:
In the below code of my Main Activity, how can I achieve what I’m looking for:
Code:
ListView list;
apps.setChoiceMode(apps.CHOICE_MODE_MULTIPLE_MODAL);
apps.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {
@Override
public void onItemCheckedStateChanged(ActionMode mode, final int position, long id, boolean checked) {
//If the item is selected in the listview list
if (list.isItemChecked(position)) {
Toast.makeText(getApplicationContext(), "CHECKED" , Toast.LENGTH_LONG).show();
//how can I maintain the original position of the filtered item????
}
//If the selection is removed for the item in the listview list
else {
Toast.makeText(getApplicationContext(), "UNCHECKED" , Toast.LENGTH_LONG).show();
}