title: Conditionally change imageButton image
body: <p>I have an imageButton inside a listview and I want to change its image depending on two cases. In the first case the imagebutton is enabled and has an image. In the second case the imagebutton is disabled and should have a different image.</p>
  
  <pre><code>public View getView(int position, View convertView, ViewGroup parent) {
  
      View vi=convertView;
      if(convertView==null)
          vi = inflater.inflate(R.layout.list_row, null);
  
      TextView title = (TextView)vi.findViewById(R.id.title); 
      TextView retail_price = (TextView)vi.findViewById(R.id.retail_price);
      TextView deal_price = (TextView)vi.findViewById(R.id.deal_price);
      TextView duration = (TextView)vi.findViewById(R.id.duration); 
      ImageView thumb_image=(ImageView)vi.findViewById(R.id.list_image);
      ImageButton imgb =  (ImageButton)vi.findViewById(R.idIMGB);
  
      HashMap&lt;String, String&gt; otherdeals = new HashMap&lt;String, String&gt;();
      otherdeals = data.get(position);
  
      title.setText(otherdeals.get(dealsparsing.TAG_TITLE));
      retail_price.setText(otherdeals.get(dealsparsing.TAG_RETAIL));
      retail_price.setPaintFlags(retail_price.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
      deal_price.setText(otherdeals.get(dealsparsing.TAG_DEAL));
     duration.setText(otherdeals.get(dealsparsing.TAG_FINAL_TIME));
     Bitmap bitmap = DownloadImage(otherdeals.get(dealsparsing.TAG_IMAGE_URL));
     thumb_image.setImageBitmap(bitmap);
  
      return vi;
  
  } 
  </code></pre>