更改按钮图像在android系统 [英] change button image in android
本文介绍了更改按钮图像在android系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想改变一个按钮的形象在我的code。我发现这个可以用XML来完成:
I want to change the image of a button in my code. I found this can be done in xml:
请检查此链接
但图像不会停留在我释放按钮后。我想按一下按钮
和按钮切换到一个新的形象。可以这样做?
but the image will not stay on after I released the button. I want to click the button and the button change to a new image. Can this be done?
感谢
推荐答案
在的onClick方法,你需要改变按钮的形象,这种方式。
in onClick method you need to change the Button's image, this way..
public void onClick(View v) {
if(v==buttonName){
buttonName.setBackgroundResource(R.drawable.imageName);
}
}
这篇关于更改按钮图像在android系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文