안드로이드 개발 질문/답변
(글 수 45,052)
class CustomCursorAdapter extends SimpleCursorAdapter {
public CustomCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to) {
super(context, layout, c, from, to);
setViewBinder(new CustomViewBinder());
}
public class CustomViewBinder implements SimpleCursorAdapter.ViewBinder {
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
String location = "_id";
int myImageIndex = cursor.getColumnIndex(location);
//Log.e("myImageIndex's value","@@ "+myImageIndex);
if (myImageIndex == columnIndex) {
ImageView typeControl = (ImageView)view;
int type = Integer.parseInt(cursor.getString(myImageIndex));
Log.e("type value",""+type);
int aaa = getResources().getIdentifier("photo"+type,"drawable","net.dongsam");
Log.e("aaa value",""+aaa);
typeControl.setImageResource(aaa);
return true;
}
return false;
}
}/* class CustomViewBinder */
} /* class CustomCursorAdapter */
}SimpleCursorAdapter를 이용해 이미지와 텍스트를 보여주려고 하는데요
저기 위에 빨갛게 표시한부분이 0으로 찍히네요 ㅠㅠ 제가 혹시 뭐 빠트린게 있나요?
리소스상에 파일 명이나 패키지명은 틀린게 없는걸 확인했구요... 뭐가 문제인지좀 알려주세요 _ _)




저도 같은 문제로 고생하다가 해결해서 짧은 글 남깁니다.
"photo"
+type 값을 다시 한번 잘 체크 해보세요 R.java에서 참조 할수 있는 값이 없으면 0값이 반환됩니다.저같은 경우에는 space가 들어가 있어서 0이 계속 return됐었습니다.님과 같은 경우는 조금 다르겠지만 확인해보세요.