How Can I Check If An Imageview Background Is A Certain Image?
so far im using something like this if (image.getDrawable() != thisContext.getResources().getDrawable(R.raw.anImage) ) { // do something } but it does not work.
Solution 1:
Basically, comparing two drawables is a pain so just convert them to bitmaps and then compare the bitmaps (much easier solution), here's the code:
Bitmap bitmap1 = ((BitmapDrawable)fDraw).getBitmap();
Bitmap bitmap2 = ((BitmapDrawable)sDraw).getBitmap();
if(bitmap1 == bitmap2)
{
do some stuff
}
Solution 2:
try converting the Drawables to Bitmap
first and then comparing:
Bitmap a = ((BitmapDrawable)d1).getBitmap();
Bitmap b = ((BitmapDrawable)d2).getBitmap();
Post a Comment for "How Can I Check If An Imageview Background Is A Certain Image?"