检测按钮图片,在安卓系统中

在安卓应用中,检测button的图片,然后修改。怎么实现?

我的代码如下:

Drawable a;
a=b1.getBackground();
int i=R.drawable.happy;
// b1 is button
if(a==R.drawable.happy)
 b1.setBackgroundResource(R.drawable.whoa);
else
 b1.setBackgroundResource(R.drawable.happy);
Drawable a = b1.getDrawable();
Drawable image = getResources().getDrawable(R.drawable.happy);
// b1 is button
if(image.equals(a))
 b1.setBackgroundResource(R.drawable.whoa);
else
 b1.setBackgroundResource(R.drawable.happy);

试试这个