안드로이드 개발 질문/답변
(글 수 45,052)
ImageButton btn1=(ImageButton)findViewById(R.id.right);
String str=getResources().getString(R.string.red_button); ->red_button은 value/string.xml에
<string name="red_button">R.drawable.red</string> <-요렇게 해놨어요
btn1.setImageDrawable(getResources().getDrawable(str)); <-이런식으로는 이미지 지정을 할수없는 건가요?
btn2.setImageDrawable(getResources().getDrawable(R.drawable.blue));
getDrawable의 파라미터로 int형을 쓰라고 나오네요 어덯게 방법이 없나요?
아님 다른방식이라도 알려주세요
실시간 체크 할꼐요
2010.10.28 22:02:50
R.string.red_button 이게 String이 아니라 int 로된 리소스 id를 반환하는거에요 왜저렇게하시는지이유는모르겠지만 R.string.red_button를 int로 받아서적용시키면되겠네요
2010.10.29 00:02:11
int str=getResources().getString(R.string.red_button); 이렇게 변환했더니 이 줄에서 에러나 나네요
도와주세요~