if(imageview == R.drawable.example){
}
希望此功能对您有帮助:
public static boolean checkImageResource(Context ctx, ImageView imageView,
int imageResource) {
boolean result = false;
if (ctx != null && imageView != null && imageView.getDrawable() != null) {
ConstantState constantState;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
constantState = ctx.getResources()
.getDrawable(imageResource, ctx.getTheme())
.getConstantState();
} else {
constantState = ctx.getResources().getDrawable(imageResource)
.getConstantState();
}
if (imageView.getDrawable().getConstantState() == constantState) {
result = true;
}
}
return result;
}