2012-12-13 6 views
0

에서 자원 ID를 가져옵니다 : 활동에서XML로 드로어 블

<ImageButton 
    android:id="@+id/b_checkEv" 
    android:src="@drawable/img_huella" 
    ... /> 

:

 ImageButton ib = (ImageButton) findViewById(R.id.b_checkEv); 
    Drawable dr = ib.getDrawble(); 

내가 ib.setDrawable와 코드 dinamically하여 ImageButton의 이미지를 변경(). 아무 때 나 ImageButton에 매 순간 어떤 이미지가 설정되어 있는지 알기 위해 Drawable에서 resouce id를 얻을 수있는 방법을 알고 있습니까?

감사합니다.

+5

이 값을 보유하는 int를 유지할 수 있습니다. 전의. int currentImage = R.drawable.image; ib.setDrawable (currentImage); – dymmeh

+0

감사합니다. – user23

답변

0

Android 버튼을 제어하는 ​​가장 좋은 방법은 태그입니다.

"ib.setTag ("image1.png ")"을 사용하고 여기에서 이미지 데이터를 관리 할 수 ​​있습니다.

그런 다음 "String imageName = ib.getTag()"를 수행하고 이미지 이름을 가져올 수 있습니다.

감사합니다.