title: How can i find which image is set in imageview from my drawable?
body: <p>I need to find which image is set in the imageview (onClick of imageview) from my drawble folder. For that I need to compare drawable of imageview's background and image from my drawable folder. I found some of methods for that but none of that works in my case. </p>
  
  <p>While debugging this problem I found one property of the imageview (on hover of imageview) named "<strong>mBackgroundResource</strong>" holds same Integer value of my image in the drawable folder. </p>
  
  <pre><code>int i = R.drawable.skype; (2130837526)
  </code></pre>
  
  <p>Imageview's <code>mBackgroundResource= 2130837526</code></p>
  
  <p>So is there any way to get mBackgroundResource value? So I can try to compare it. Can anyone help to solve this? </p>
  
  <p>Here is my code.</p>
  
  <p>I am in adapter so,</p>
  
  <pre><code>Context mContext;
  Drawable skype;
  
  skype = mContext.getResources().getDrawable(R.drawable.skype); // in the constructor of the adapter.
  
  public void onClick(View v)
      {   
          ImageView img = (ImageView)v.findViewById(R.id.img_call_icon);
          Drawable img_id = img.getBackground();
      }
  </code></pre>
  
  <p>Now I've tried following..(Where am I missing ?)</p>
  
  <pre><code>/***********************************************************************************/
  
      if(img_id == skype)
      {
          // Not working...
      }
  
  /***********************************************************************************/
  Bitmap bitmap = ((BitmapDrawable)img_id).getBitmap();
  Bitmap bitmap1 = ((BitmapDrawable)skype).getBitmap();
  
  if(bitmap == bitmap1)
  {
      // Not working...
  }
  /***********************************************************************************/
  Object tag = img.getTag();
  int i = R.drawable.skype;
  
  if(tag != null &amp;&amp; ((Integer)tag).intValue() == i)
  {
     // Not working...
  }
  /***********************************************************************************/
  int j = ((Integer)tag).intValue() ; // always return 0..
  int i = R.drawable.skype;
  
  if(i == j)
  {
     // Not working...
  }
  /***********************************************************************************/
  Boolean b = img_id.equals(skype); // return FALSE, Not working...
  /***********************************************************************************/
  ImageView imageView = (ImageView)v.findViewById(R.id.img_call_icon);
  assert(i == imageView.getId());
  Integer integer = (Integer) imageView.getTag(); // always fill with null...
  integer = integer == null ? 0 : integer;
     switch(integer) 
     {
     case R.drawable.skype:
         Toast.makeText(mContext, "skype", Toast.LENGTH_SHORT).show();
         break;
  
     case R.drawable.call:
         Toast.makeText(mContext, "call", Toast.LENGTH_SHORT).show();
         break;
     } // Not working...
  </code></pre>