반응형
R.java 를 참조하지 않고 리소스 얻어오기
getIdentifier 의 첫번째 인자 는 리소스 이름
두번째 인자 "string" 같은경우
resource xml 의 element 이름 적어주거나
"drawable" 로 Drawable도 얻어올수 있다.
int resId = context.getResources().getIdentifier(resName, "string", context.getPackageName());
String str = context.getString(resId);
= context.getResouces().getString(resId);
int resId = context.getResources().getIdentifier(resName, "drawable", context.getPackageName());
Drawable = context.getResources().getDrawable(redId);
String str = context.getString(resId);
= context.getResouces().getString(resId);
int resId = context.getResources().getIdentifier(resName, "drawable", context.getPackageName());
Drawable = context.getResources().getDrawable(redId);
getIdentifier 의 첫번째 인자 는 리소스 이름
두번째 인자 "string" 같은경우
resource xml 의 element 이름 적어주거나
"drawable" 로 Drawable도 얻어올수 있다.
반응형
'지식쌓기 > 개발-Android' 카테고리의 다른 글
| Android - get MapView Api (google maps) (2) | 2010.05.06 |
|---|---|
| Android - Scanning Media files (2) | 2010.03.08 |
| Android - resultCode from TabActivity (6) | 2009.10.26 |
| Android - MimeType으로 image얻어오기 (3) | 2009.05.26 |
| Android - Change Tab Background (7) | 2009.05.21 |