@Override protected FilterResults performFiltering(CharSequence constraint) { String filtro = constraint.toString().toLowerCase(); FilterResults results = new FilterResults(); infoComunAdaptersFiltrados.clear(); for (IInfoComumAdapter infoComumAdapter : infoComunAdapters) { if (infoComumAdapter.getValorAdapater().toLowerCase().contains(filtro) || infoComumAdapter.getInfoValorAdapter().toLowerCase().contains(filtro)) { infoComunAdaptersFiltrados.add((T) infoComumAdapter); } } results.values = infoComunAdaptersFiltrados; results.count = infoComunAdaptersFiltrados.size(); return results; }
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { LayoutInflater layoutInflater = LayoutInflater.from(context); convertView = layoutInflater.inflate(R.layout.adapter_info_comum_list_view, null); } LinearLayout llLinha = (LinearLayout) convertView.findViewById(R.id.llLinha); if (position % 2 == 0) llLinha.setBackgroundColor(context.getResources().getColor(R.color.comprasFacil_cinza_claro)); else llLinha.setBackgroundColor(context.getResources().getColor(R.color.comprasFacil_branco)); IInfoComumAdapter iInfoComumAdapter = (IInfoComumAdapter) getItem(position); if (iInfoComumAdapter != null) { TextView label = (TextView) convertView.findViewById(R.id.label); label.setText(iInfoComumAdapter.getValorAdapater()); TextView extraInfo = (TextView) convertView.findViewById(R.id.extraInfo); extraInfo.setText(iInfoComumAdapter.getInfoValorAdapter()); } return convertView; }