我的视图上有一个图像按钮,我需要在用户交互后更改它。我没有找到类似的东西myImageButton.setDrawable
这是我想要更改的按钮的 xml:
<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"
to android:src="@drawable/btn_stop"
以编程方式。这可以做到吗?提前致谢。
您可以使用
setImageResource for the image button
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)