I am new to android.
My custom adapter throws an exception while filtering.
here is my code. private class DeptAdapter extends ArrayAdapter implements Filterable {
private ArrayList<Dept> items; private ArrayList<Dept> mOriginalValues; public DeptAdapter(Context context, int textViewResourceId, ArrayList<Dept> items) { super(context, textViewResourceId, items); this.items = items; } @Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.item_listview_2line, null); } Dept d = items.get(position); if (d != null) { TextView tt = (TextView) v.findViewById(R.id.toptext); TextView bt = (TextView) v.findViewById(R.id.bottomtext); if (tt != null){ tt.setText(d.dept_nm); } if(bt != null){ bt.setText(d.dept_cd); } } return v; } @Override public Filter getFilter() { Filter filter = new Filter() { @SuppressWarnings("unchecked") @Override protected void publishResults(CharSequence constraint,FilterResults results) { items = (ArrayList<Dept>) results.values;
help me to anyone .... I can't understand why the getView () method was called more than items.size ()
android filter custom-adapter
user1788012
source share