android - Can't clear selected items on list view onDestroyActionMode - API 19 -


my items in list view activity not cleared, i.e. remain checked internally.

    @override             public boolean onactionitemclicked(actionmode mode,                     menuitem item) {                  if(item.gettitle() == "add")                 {                     intent returnintent = new intent();                     arraylist<string> path = new arraylist<string>();                     sparsebooleanarray checked = listview.getcheckeditempositions();                     for(int i=0; i<checked.size(); i++)                     {                         if(checked.valueat(i)){                             musicitem mitem = (musicitem) listview.getitematposition(i);                             path.add(mitem.getabsolutepath());                         }                     }                     returnintent.putstringarraylistextra("path", path);                     setresult(result_ok, returnintent);                                             mode.finish();                     finish();                     return true;                 }                  return false;             } 

i guess part i'm doing wrong here!!

    @override             public void ondestroyactionmode(actionmode mode) {                 listview.clearchoices();                 for(int i=0; i<listview.getchildcount(); i++){                     listview.setitemchecked(i, false);                 }             } 

the loop in 'ondestroyactionmode' gives "stackoverflowerror". , 'clearchoices()' doesn't work reason. appreciated!! thank you!

the following loop gave me "stackoverflowerror" when put in "ondestroyactionmode"

    for(int i=0; i<listview.getcount(); i++)     {         listview.setitemchecked(i, false);     } 

but when put on 'oncreate' of list view activity. worked fine. no idea why though. solution find none of solutions posted here worked me: listview selection remains persistent after exiting choice mode


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -