我想更改例如btn_star_big_off to btn_star_big_on單擊時更改圖像按鈕系統資源
每次有人點擊按鈕時,該狀態都會改變。 Toogle將是完美的,但我不知道如何結合。而且我不知道如何改變按鈕的狀態。我發現我可以用可繪製的XML文件做到這一點,但我只能訪問我導入的圖像,但不能訪問系統資源的圖像?
的按鈕:
<ImageButton
android:id="@+id/imageButton4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star_big_off" />
這裏是從我的繪製XML審判:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/button" android:state_pressed="true"/>
<!-- pressed -->
<item android:drawable="@drawable/button"/>
<!-- default -->
</selector>
嘗試改變的圖像編程onclick事件創建XML佈局你的視圖。 – AndiM