Filtering a ListView with Baseadapter filters text not images

后端 未结 4 1842
一向
一向 2020-12-18 07:29

There was some progress made to the earlier problem. Now there is a new problem. The text in the GridView shows the correct result. However, the images are the same as at th

4条回答
  •  抹茶落季
    2020-12-18 08:16

    @MKJParekh did a great job!To sum up his implementation:

    1. Declare a temporary List of objects at the beginning of the class that reflect the incoming data used for each item (1 object per item).
    2. In the performFiltering()set the condition for nulls and empty strings, and also if the constraint matches the string value of the corresponding object, then add the object to the temp List. That way you have only a "filtered" list of objects.
    3. Use data from your temp list, rather than your data source (as you normally would), for methods such as getCount(), getItem(), and getView(). Otherwise, you'll just be loading ALL the items everytime, since untimately notifyDataSetChanged() will be called after each filtering.

提交回复
热议问题