0
在XML中獲取資源ID:從繪製
<ImageButton
android:id="@+id/b_checkEv"
android:src="@drawable/img_huella"
... />
在活動:
ImageButton ib = (ImageButton) findViewById(R.id.b_checkEv);
Drawable dr = ib.getDrawble();
我改變dinamically的ImageButton的形象在代碼ib.setDrawable()。 任何人都知道如何從Drawable中獲取資源ID以便知道在每個時刻在ImageButton中設置了哪個圖像?
謝謝!
你可以維護一個int值來保存這個值。恩。 int currentImage = R.drawable.image; ib.setDrawable(currentImage); – dymmeh
它有幫助,謝謝! – user23