XML
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton1"
android:src="@drawable/image1"
android:onClick="buttonClick"
/>
JAVA
--------------------
public void buttonClick(View v)
{
Button aButton = (Button)v;
aButton.setBackgroundResource(R.drawable.image2);
}
这是我到目前为止没有运气的尝试......
我希望能够单击按钮并将图像更改为 image2,还有其他图像我将根据其他变量将其更改为。我真的被卡住了。我会继续研究其他问题,如果我找到答案,我会在这里发布。