ボタンがあります
Button button = (Button)findViewById(R.id.button);
button.setBakgroundResource(R.drawable.icon);
どのバックグラウンド リソース ボタンがあるかを確認したい場合、それは可能ですか? どうやって。
例えば :
if (button.getResourceId()==R.drawable.icon)
何かをする...
更新: 条件は FALSE です 本当であってほしい 画像が一致しません
vi.findViewById(R.id.button1).setOnClickListener(新しいOnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
v.findViewById(R.id.button1).setBackgroundResource(R.drawable.boutton_off);
Drawable aImg = (Drawable)v.findViewById(R.id.button1).getBackground();
Drawable bImg = v.getResources().getDrawable(R.drawable.boutton_off);
if(aImg==bImg){
System.out.println("On");
}else
System.out.println("off");
//main.popMessage(position);
}
});