이미지 뷰 아이디를 문자열로 넘기고 싶습니다.
텍스트 뷰 아이디는 바꾸는 방법이 있따길래 이미지 뷰에도 적용해보았더니 되질 않습니다.
ImageView position2 = (ImageView)findViewById(R.id.img_position2);//포지션 이미지
BitmapDrawable img_position = null;
if(str.equals("ST")){
img_position = (BitmapDrawable)getResources().getDrawable(R.drawable.st);
position2.setImageDrawable(img_position);
}
이러한 소스를
public void setting(String str)
ImageView position = (ImageView)findViewById(R.id.img_position);//포지션 이미지
BitmapDrawable img_position = null;
String type = "id";
String pack = getPackageName();
int viewId = getResources().getIdentifier(str, type, pack);
img_position = (BitmapDrawable)getResources().getDrawable(viewId);
position.setImageDrawable(img_position);
이런식으로 바꿔줬는데 사용하는 함수가 다른건가요