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:
Bitmapbitmap1= ((BitmapDrawable)fDraw).getBitmap();
Bitmapbitmap2= ((BitmapDrawable)sDraw).getBitmap();
if(bitmap1 == bitmap2)
{
do some stuff
}
Solution 2:
try converting the Drawables to Bitmap
first and then comparing:
Bitmapa= ((BitmapDrawable)d1).getBitmap();
Bitmapb= ((BitmapDrawable)d2).getBitmap();
Post a Comment for "How Can I Check If An Imageview Background Is A Certain Image?"