title: Implementing Search Function to search in ListView by specific TextView
body: <p>[Auction List Image][1] I am trying to implement a search function to search through the ListView by a specific TextView which is the ItemName TextView as shown in the image such as "Adidas Shoes" &amp; "Nike Shoes" .That TextView is id as txtName. Currently, with these codes, there is no error, but the search function is not doing anything. How do I implement the search to actually search by looking through the txtName TextView?</p>
  
  <p>Adapter:</p>
  
  <pre><code>public class AuctionListAdapter extends BaseAdapter implements Filterable {
  
  ValueFilter valueFilter;
  
  
  private Context context;
  private int layout;
  private ArrayList&lt;Model&gt; auctionList;
  
  
  
  
  public AuctionListAdapter(Context context, int layout, ArrayList&lt;Model&gt; auctionList) {
      this.context = context;
      this.layout = layout;
      this.auctionList = auctionList;
  }
  
  @Override
  public int getCount() {
      return auctionList.size();
  }
  
  @Override
  public Object getItem(int position) {
      return auctionList.get(position);
  }
  
  
  @Override
  public long getItemId(int position) {
      return position;
  }
  
  @Override
  public Filter getFilter() {
      if (valueFilter == null) {
          valueFilter = new ValueFilter();
      }
      return valueFilter;
  }
  
  private class ValueFilter extends Filter {
      @Override
      protected FilterResults performFiltering(CharSequence constraint) {
          FilterResults results = new FilterResults();
  
          if (constraint != null &amp;&amp; constraint.length() &gt; 0) {
              ArrayList&lt;Model&gt; filterList = new ArrayList&lt;Model&gt;();
              for (int i = 0; i &lt; auctionList.size(); i++) {
                  if ((auctionList.get(i).getName().toUpperCase())
                          .contains(constraint.toString().toUpperCase())) {
                      Model model = new Model(auctionList.get(i).getId(),auctionList.get(i).getName(),
                              auctionList.get(i).getDescription(),auctionList.get(i).getPrice(),auctionList.get(i).getDuration()
                      ,auctionList.get(i).getImage());
                          filterList.add(model);
  
  
                  }
              }
              results.count = filterList.size();
              results.values = filterList;
          } else {
              results.count = auctionList.size();
              results.values = auctionList;
          }
          return results;
  
      }
  
      @Override
      protected void publishResults(CharSequence constraint,
                                    FilterResults results) {
          auctionList = (ArrayList&lt;Model&gt;) results.values;
          notifyDataSetChanged();
      }
  }
  
  
  
  private class ViewHolder{
      ImageView imageView;
      TextView txtName,txtDescription,txtPrice,txtDuration;
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
      View row = convertView;
      ViewHolder holder = new ViewHolder();
  
      if(row == null){
          LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          row = inflater.inflate(layout,null);
          holder.txtName=row.findViewById(R.id.txtName);
          holder.txtDescription=row.findViewById(R.id.txtDescription);
          holder.txtPrice=row.findViewById(R.id.txtPrice);
          holder.txtDuration=row.findViewById(R.id.txtDuration);
          holder.imageView=row.findViewById(R.id.imgIcon);
          row.setTag(holder);
      }
      else{
          holder = (ViewHolder)row.getTag();
      }
      Model model = auctionList.get(position);
  
      holder.txtName.setText(model.getName());
      holder.txtDescription.setText(model.getDescription());
      holder.txtPrice.setText(model.getPrice());
      holder.txtDuration.setText(model.getDuration());
  
  
      byte[] auctionImage = model.getImage();
      Bitmap bitmap = BitmapFactory.decodeByteArray(auctionImage,0,auctionImage.length);
      holder.imageView.setImageBitmap(bitmap);
      return row;
  }
  
  
  }
  </code></pre>
  
  <p>AuctionList.java:</p>
  
  <pre><code>@Override
  public boolean onCreateOptionsMenu(Menu menu) {
      getMenuInflater().inflate(R.menu.searchmenu,menu);
  
      MenuItem myActionMenuItem = menu.findItem(R.id.action_search);
      SearchView searchView = (SearchView)myActionMenuItem.getActionView();
  
      searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
          @Override
          public boolean onQueryTextSubmit(String text) {
  
              return false;
          }
  
          @Override
          public boolean onQueryTextChange(String newText) {
              mAdapter.getFilter().filter(newText);
              return false;
          }
      });
  
  
      return super.onCreateOptionsMenu(menu);
  }
  </code></pre>