Issues with SearchVIew in Recycler Android -


i working on on app keeps track of someones expenses, user adds have purchased , keeps track of that, expenses displayed in recyclerview, there comes time when 1 has many items , needs search hence added search functionality working find, because dealing expenses adapter has check box indicate if or not expense has been paid for, when search item , tick have been paid feature works fine exit search mode notice something, item goes original position in list item occupies position modified item inherits paid state, ticked paid well, explanation makes sense, here screen shots demonstrate mean:

in first screen shot have normal list search dgdfcurrently dgdf @ position 1

enter image description here

after search dgdfit takes position 0 in array

enter image description here

since have item looking in case dgdf decide mark paid do

enter image description here

but here issue exist edit-mode item takes position 0 ticked paid for

enter image description here

below code using searching:

    protected filterresults performfiltering(charsequence constraint) {             final filterresults oreturn = new filterresults();             final arraylist<expense> results = new arraylist<>();              //i thought loading new data database each time             // did not @             filtersearch = database.getallexpenses();             if (constraint != null) {                 if (filtersearch != null & filtersearch.size() > 0)                 {                     (expense g : filtersearch)                         if (g.getmerchantname().tolowercase().contains(constraint.tostring().tolowercase()))                             results.add(g);                     oreturn.values = results;                 }             }             return oreturn;         }   @override         protected void publishresults(charsequence constraint, filterresults results) {              //update adapter arraylist             adapterexpenselist = (arraylist<expense>) results.values;             notifydatasetchanged();           } 

i figured out problem, apparently alright search algorithm, issue code responsible ticking checkboxes, checking 1 side, is,

      if (expense.getischecked() == 1)         holder.checkbox.setchecked(true);        else         holder.checkbox.setchecked(false) 

but @ time performing check checkbox set true hence there no way of unchecking it, did this

 if (expense.getischecked() == 1)         holder.checkbox.setchecked(true);       if (expense.getischecked() == 0)         holder.checkbox.setchecked(false); 

i had check both occurrences, whether or not true or false, , works fine now.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -