【发布时间】:2016-01-01 16:29:30
【问题描述】:
我的应用程序中有几个按钮可以有不同的背景图像。
现在,在OnClick 函数中,我需要检查背景图像是否是drawable 中的图像名称“williboese”。
我试过这样:
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
//b.setBackgroundColor(R.color.redwue);
count++;
if(arg0.getResources().equals(R.drawable.williboese)){
Toast.makeText(MainActivity.this, "heeeee", Toast.LENGTH_SHORT).show();
}
}
});
我现在知道b 有这个背景图片,但没有显示 Toast。我做错了什么?
【问题讨论】:
-
设置资源时为按钮设置标签并检查标签
标签: android image background