Skip to content Skip to sidebar Skip to footer

How To Filter Data Date Wise Location Wiase In Given Example Within Same List

package com.nous.demoexample; import static com.nous.demoexample.Constant.EIGTH_COLUMN; import static com.nous.demoexample.Constant.FIFTH_COLUMN; impo

Solution 1:

If you are using EditText to search then you have to write your own filter method..here is an example Custom ListView Search .

you have to change filter method something like this.

public void filter(String charText) {
    charText = charText.toLowerCase(Locale.getDefault());
    worldpopulationlist.clear();
    if (charText.length() == 0) {
        worldpopulationlist.addAll(arraylist);
    } else {
        for (WorldPopulation wp : arraylist) {
            if(isDate)
            {
              if (wp.getDate().toLowerCase(Locale.getDefault()).contains(charText))
              {
                  worldpopulationlist.add(wp);
              }
            }else{
             if(wp.getLocation().toLowerCase(Locale.getDefault()).contains(charText))  
              {
                worldpopulationlist.add(wp);
              }  
            }

        }
    }
    notifyDataSetChanged();
}

Post a Comment for "How To Filter Data Date Wise Location Wiase In Given Example Within Same List"