如何以编程方式替换/更改图像按钮android [英] how to replace/change image button programmatically android
本文介绍了如何以编程方式替换/更改图像按钮android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的视图上有一个图像按钮,需要在用户交互后进行更改.我找不到类似myImageButton.setDrawable
的东西,这是我要更改的按钮的xml:
I have an image button on my view which i need to change after user interaction. I dont find nothing like myImageButton.setDrawable
Here is my xml for the button i want to change:
<ImageButton
android:id="@+id/stopButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/buttons_background"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:background="@null"
android:src="@drawable/btn_play" />
我唯一需要以编程方式将android:src="@drawable/btn_play"
更改为android:src="@drawable/btn_stop"
的行.能做到吗?预先感谢.
The only line I need to change android:src="@drawable/btn_play"
to android:src="@drawable/btn_stop"
programmatically. Can this be done? Thanks in advance.
推荐答案
您可以使用
setImageResource for the image button
这篇关于如何以编程方式替换/更改图像按钮android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文