title: ImageView inside listview getting changed on search refresh
body: <p>I have a <code>listview</code> which contains <code>TextView</code> and <code>ImageView</code>.</p>
  
  <p>Here it is: </p>
  
  <p><img src="https://i.stack.imgur.com/T3BCA.png" alt="enter image description here"> </p>
  
  <p><code>OnClick</code> of <code>ImageView</code> changes opens an <code>alertdialog</code> with buttons Yes and No.</p>
  
  <p><img src="https://i.stack.imgur.com/szd7m.png" alt="enter image description here"></p>
  
  <p>if press Yes</p>
  
  <p><code>imageView</code> changes its background to blue, </p>
  
  <p>if press no, </p>
  
  <p><code>imageView</code> background  changes to red.</p>
  
  <p><img src="https://i.stack.imgur.com/t933S.png" alt="enter image description here"></p>
  
  <p>Till now it is working fine. </p>
  
  <p>I have a search <code>edittext</code> above the <code>listview</code>, which searches based on the <code>textview</code> in the <code>listview</code>. </p>
  
  <p>Now on searching, the <code>imageview</code> is not showing the changed background, but the default background only. See this:</p>
  
  <p><img src="https://i.stack.imgur.com/sIooM.png" alt="enter image description here"></p>
  
  <p>What should I do to make the <code>imageview</code> show the image which was selected in the alert dialog.</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>@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.custom_lay, null);
    }else{
      v=convertView;
    }
    holder = new ViewHolder();
      holder.code = (TextView) v.findViewById(R.id.DealerName);
    holder.btnName = (ImageView) v.findViewById(R.id.BtnStreet); 
      holder.btnName.setOnClickListener(new OnClickListener() {
  
     @Override
     public void onClick(final View vi) {
      // TODO Auto-generated method stub
      AlertDialog.Builder builder = new AlertDialog.Builder(context);
      builder.setMessage("select any one?");
      builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int which) {
  
  
  
  //       holder.btnName.setBackgroundResource(R.drawable.green_icon);
       vi.setBackgroundResource(R.drawable.blue_icon);
  //     notifyDataSetChanged();
      }
      });
      builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
       public void onClick(DialogInterface dialog, int which) {
  
        holder.btnName.setImageResource(R.drawable.blue_icon);
        //vi.setBackgroundResource(R.drawable.green_icon);
  //      notifyDataSetChanged();
       }
      });
      AlertDialog dialog = builder.create();
      dialog.show();
     }
    });
       v.setTag(holder);
       ViewHolder hold = (ViewHolder) v.getTag();
      String lb = DisplayedValues.get(position);
      hold.code.setText(getItem(position));
  //   hold.btnName.setBackgroundResource(getSelectedItemPosition());
  
    return v;
   }
  </code></pre>