4
好吧,那我怎麼當點擊一個按鈕?它會改變一個圖像以不同的圖像Android java更改可繪製圖像
我我想改變的時候按下按鈕圖像的XML:
<ImageView
android:id="@+id/bluebtn1"
android:src="@drawable/buttonblue"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginLeft="33dp"
android:layout_marginTop="140dp"></ImageView>
這裏是我的Java代碼生病做,當你按下按鈕
case R.id.redbtn1:
if (lvl1.getText().equals("1")) {
lvl1.setText("2");
// Here is where the code goes to change the image
} else {
Toast.makeText(main.this, "YOU LOSE!", Toast.LENGTH_SHORT).show();
}
break;
再次感謝blessenm!我會在8分鐘內投票!(我必須等那麼久) –