Issue
I want a certain action to be done if the image of my ImageButton button
is equal to a drawable. Like this:
if (button.getBackground().getConstantState()==getResources().getDrawable(R.drawable.mydrawable).getConstantState())
{
//perform action//
}
But if I do so, getDrawable
gets red underline and I don't know why?
Can anyone help me?
Solution
First
ImageButton temp = findViewById(R.id.myImagebtn);
Bitmap imageBtm = ((BitmapDrawable)temp.getDrawable()).getBitmap();
Drawable myDrawable = getResources().getDrawable(R.drawable.apple);
Bitmap appleBtm = ((BitmapDrawable) myDrawable).getBitmap();
second
if(imageBtm.sameAs(appleBtm))
{
Log.i("Bitmap compare", "equal");
}
Answered By - sina akbary
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.