Hello,
I have a list view where I am filtering items through a SearchView. on activating the state for an item, it is not getting the correct item instead getting it from the position. To make it more clear, please refer to the below screenshots:
1. Searched for keyword com and selected the filtered item (i.e activated_state)
2. On clearing the filter, when the position of the items changes it does not keep track of the selected item:
I want the selection to be correct regardless of the position change.
My code in MainActivity for this section:
I am using an extended baseAdapter, please let me know if you need to see that code as well.
I have a list view where I am filtering items through a SearchView. on activating the state for an item, it is not getting the correct item instead getting it from the position. To make it more clear, please refer to the below screenshots:
1. Searched for keyword com and selected the filtered item (i.e activated_state)
2. On clearing the filter, when the position of the items changes it does not keep track of the selected item:
I want the selection to be correct regardless of the position change.
My code in MainActivity for this section:
Code:
apps.setChoiceMode(apps.CHOICE_MODE_MULTIPLE_MODAL);
apps.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {
[USER=1021285]@override[/USER]
public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
if (apps.isItemChecked(position)) {
Adapter.getItem(position);
Toast.makeText(getApplicationContext(), "CHECKED", Toast.LENGTH_LONG).show();
count = count + 1;
mode.setTitle(count + "items selected");
list_apps.add(Adapter.filteredData.get(position).packageName);
list_apps.trimToSize();
}
else {
Toast.makeText(getApplicationContext(), "UNCHECKED" , Toast.LENGTH_LONG).show();
count--;
mode.setTitle(count + "items selected");
list_apps.remove(Adapter.filteredData.get(position).packageName);
list_apps.trimToSize();
}
I am using an extended baseAdapter, please let me know if you need to see that code as well.