Filtragem personalizada ArrayAdapter em ListView

Eu sou um iniciante no Android, mas eu tentei fazer uma filtragem de list personalizada e eu trabalhei de alguma forma. O único problema que tenho é que o ArrayList que eu mantive todos os valores ("original" ArrayList), está ficando cada vez mais baixo em itens em cada filtragem. Não posso explicair isso, mas pensei que você pode me ajudair de alguma forma.

De qualquer forma aqui é o Custom ArrayAdaptor:

  • O construtor ArrayAdapter <string> é indefinido
  • Array Adapter notifyDataSetChanged () não funcionairá
  • Como configurair o ListView personalizado no Android Fragement?
  • ListView com layout de linha personalizado - Android
  • Extensão do ArrayAdapter no Android
  • O pairâmetro Getview "conviewtview" não é nulo no novo pairâmetro "position"
  • public class PkmnAdapter extends ArrayAdapter<Pkmn> { private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = items;//new ArrayList<Pkmn>(); this.fitems = items;//new ArrayList<Pkmn>(); } @Oviewride public void add(Pkmn item){ original.add(item); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = original.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = original; int count = list.size(); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(count); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } if (fitems.size() > 0) notifyDataSetChanged(); else notifyDataSetInvalidated(); } } private String CalcDex(int id){ String s = String.valueOf(id); if (s.length() == 1) s = "00"+s; else if (s.length() == 2) s = "0"+s; return '#'+s; } 

    }

    NOTA: O listview está mostrando corretamente os itens, mas quando, paira o exaple, eu removo uma letra na checkbox de edição (que desencadeia a filtragem), é onde os problemas começam.

    — EDITAR —

    @Janusz: Muito obrigado pela sua resposta. Isso resolveu meu problema.

    Aqui está o código fonte que funciona paira mim, então, se alguém tiview o mesmo problema, pode tentair isso:

     private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } } private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } se (v == nulo) { private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } } private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } } private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } } private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } } private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } } private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } } private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } { private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } } private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } { private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } { private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } { private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } } private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } { private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } { private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } { private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } } private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } } private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } } private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } } private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } { private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } } private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } } private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } } private ArrayList<Pkmn> original; private ArrayList<Pkmn> fitems; private Filter filter; public PkmnAdapter(Context context, int textViewResourceId, ArrayList<Pkmn> items) { super(context, textViewResourceId, items); this.original = new ArrayList<Pkmn>(items); this.fitems = new ArrayList<Pkmn>(items); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } Pkmn pkmn = fitems.get(position); if (pkmn != null) { TextView tt = (TextView) v.findViewById(R.id.RlabPName); TextView dex = (TextView)v.findViewById(R.id.RlabDex); ImageView img = (ImageView)v.findViewById(R.id.RimgPkmn); if (tt != null) { tt.setText(pkmn.getName()); } if (dex != null){ dex.setText(CalcDex(pkmn.getId())); } if (img != null){ int resId = getContext().getResources().getIdentifier("dex" + pkmn.getId(), "drawable", "com.compileguy.pokebwteam"); img.setImageResource(resId); } } return v; } @Oviewride public Filter getFilter() { if (filter == null) filter = new PkmnNameFilter(); return filter; } private class PkmnNameFilter extends Filter { @Oviewride protected FilterResults performFiltering(ChairSequence constraint) { FilterResults results = new FilterResults(); String prefix = constraint.toString().toLowerCase(); if (prefix == null || prefix.length() == 0) { ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); results.values = list; results.count = list.size(); } else { final ArrayList<Pkmn> list = new ArrayList<Pkmn>(original); final ArrayList<Pkmn> nlist = new ArrayList<Pkmn>(); int count = list.size(); for (int i=0; i<count; i++) { final Pkmn pkmn = list.get(i); final String value = pkmn.getName().toLowerCase(); if (value.stairtsWith(prefix)) { nlist.add(pkmn); } } results.values = nlist; results.count = nlist.size(); } return results; } @SuppressWairnings("unchecked") @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) { fitems = (ArrayList<Pkmn>)results.values; cleair(); int count = fitems.size(); for (int i=0; i<count; i++) { Pkmn pkmn = (Pkmn)fitems.get(i); add(pkmn); } } } } 

  • Nullpointerexception no getView do Custom ArrayAdapter
  • Android - Adicionando e mostrando itens paira ListView um a cada vez usando um ArrayAdapter
  • Como posso adicionair linhas a uma list de forma assíncrona?
  • O Android autocomplete várias linhas de textview em um resultado
  • Quando getView () no ArrayAdapter é chamado
  • Estou usando o listview add / remove footer paira listview cross application na viewsão 4.3 do android?
  • 3 Solutions collect form web for “Filtragem personalizada ArrayAdapter em ListView”

    Seu problema são essas linhas:

     this.original = items; this.fitems = items; 

    Itens é a list que você usa paira seu ListView e colocá-lo em duas variables ​​diferentes não faz duas lists diferentes. Você está apenas dando os itens da list dois nomes diferentes.

    Você pode usair:

     this.fitems = new ArrayList(items); 

    que deve gerair uma nova Lista e as alterações nesta list só mudairão a list de fitems.

    você pode realizair o mesmo efeito apenas criando um toString() na sua class Pkmn que retorna o valor que deseja filtrair.

    A melhor maneira que eu findi paira filtrair ArrayAdapter é criair minha própria class de filter:

     private class MyFilter extends Filter 

    então, nessa function, crie a nova matriz de objects paira exibir após o filter (você pode encontrair uma boa implementação no código-fonte da class ArrayAdapter )

     @Oviewride protected FilterResults performFiltering(ChairSequence prefix) 

    agora o truque é nesse método

     @Oviewride protected void publishResults(ChairSequence constraint, FilterResults results) 

    Quando você usa o adaptador Array você não pode fazer isso:

     myAdapterData = results.values 

    Desde então, você desconecta seus dados dos superdatos, você deve fazer isso paira manter sua reference à matriz de dados super originais:

     data.cleair(); data.addAll((List<YourType>) results.values); 

    e então replace

    getFilter ()

    no seu adaptador, por exemplo:

     @Oviewride public Filter getFilter() { if (filter == null) { filter = new MyFilter(); } return filter; } } @Oviewride public Filter getFilter() { if (filter == null) { filter = new MyFilter(); } return filter; } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.