public void filter(final String text) { String charText = text.toLowerCase(Locale.US); this.mList.clear(); if (charText.length() == 0) { this.mList.addAll(this.mArraylist); } else { for (Company company : this.mArraylist) { if (company.getName().toLowerCase(Locale.US).contains(charText)) { this.mList.add(company); } } } notifyDataSetChanged(); }
@Override public View getView(final int position, final View convertView, final ViewGroup parent) { View view = convertView; ViewHolder viewHolder = null; if (view == null) { view = sInflater.inflate(R.layout.view_location_list_item, parent, false); viewHolder = new ViewHolder(); viewHolder.mItemView = (LocationItemView) view.findViewById(R.id.list_item); view.setTag(viewHolder); } else { viewHolder = (ViewHolder) view.getTag(); } Company item = getItem(position); if (item != null) { if (item.getName().equals(this.mActiveCompany.getName())) { viewHolder.mItemView.setValues(item, true); } else { viewHolder.mItemView.setValues(item, false); } } return view; }