我的 View 上有一个图像按钮,我需要在用户交互后对其进行更改。我没有找到像 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"
更改为 android:src="@drawable/btn_stop"
的唯一一行。这可以做到吗?提前致谢。
最佳答案
你可以使用
setImageResource for the image button
关于java - 如何以编程方式替换/更改图像按钮android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16526112/