R.java 를 참조하지 않고 리소스 얻어오기

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);

getIdentifier 의 첫번째 인자 는 리소스 이름
두번째 인자 "string" 같은경우
resource xml 의 element 이름 적어주거나
"drawable" 로 Drawable도 얻어올수 있다.


저작자 표시 비영리 변경 금지
Posted by 유야
TAG

댓글을 달아 주세요

  1. BlogIcon 무적조로™ 2010/01/23 19:53  댓글주소  수정/삭제  댓글쓰기

    음... 아직은 내가 아무것도 몰라서;;;
    이거 봐도 무슨 말인지 모르겠다 ㅋㅋ
    지금 열심히 책봐야지

  2. BlogIcon 무적조로™ 2010/01/28 00:12  댓글주소  수정/삭제  댓글쓰기

    별로 쓸일이 없어도...
    나중에 궁금한거 있으면 물어볼께 ㅋㅋㅋ
    나중에 모른척하고 안갈쳐주면 안데~ㅋㅋ

  3. BlogIcon 비요뜨 2010/03/06 06:08  댓글주소  수정/삭제  댓글쓰기

    블로그로 퍼갈게요~~ 비공개로

  4. zz 2010/12/27 15:55  댓글주소  수정/삭제  댓글쓰기

    담아갈게요~^^