I want to filter my listview data where I am using custom list adapter and using ArrayList to store the data inside that. I am store data like users name, address. But I don't how I can filter the data. I want to filter data by name. Can anyone help me out? Custom list adapter code
public class ListAdapter extends BaseAdapter {
Context context;
ArrayList<String> name;
ArrayList<String> id ;
ArrayList<String> add1 ;
ArrayList<String> add2 ;
ArrayList<String> city ;
public ListAdapter(
Context context2,
ArrayList<String> id,
ArrayList<String> name,
ArrayList<String> add1,
ArrayList<String> add2,
ArrayList<String> city
)
{
this.context = context2;
this.id = id;
this.name = name;
this.add1 = add1;
this.add2 = add2;
this.city = city;
}
public int getCount() {
return id.size();
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return 0;
}
public View getView(int position, View child, ViewGroup parent) {
Holder holder;
LayoutInflater layoutInflater;
if (child == null) {
layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
child = layoutInflater.inflate(R.layout.listviewdatalayout, null);
holder = new Holder();
holder.account_master_name = (TextView) child.findViewById(R.id.account_master_name);
holder.account_master_add = (TextView) child.findViewById(R.id.account_master_add);
child.setTag(holder);
} else {
holder = (Holder) child.getTag();
}
holder.account_master_name.setText(id.get(position)+ "\t"+ name.get(position));
holder.account_master_add.setText(add1.get(position)+""+add2.get(position)+city.get(position));
return child;
}
public class Holder {
TextView account_master_name;
TextView account_master_add;
}
}