안드로이드 개발 질문/답변
(글 수 45,052)
String strquery2 = "SELECT friend FROM friendlist WHERE memId='"+command+"'";
cursor = db.rawQuery(strquery2, null);
SimpleCursorAdapter FriendAdapter=null;
FriendAdapter = new SimpleCursorAdapter(UserInfo.this,android.R.layout.simple_list_item_1, cursor,
new String[] {"friend"}, new int[] {android.R.id.text1});
ListView FriendList = (ListView)findViewById(R.id.friendlist);
FriendList.setAdapter(FriendAdapter);
db테이블요소로는 memId와 friend가 있습니다.
친구목록을 DB에서 불러와서 listview로 출력 하려고 하는데요, simplecursoradapter에서 자꾸 에러가 나네요..;;
뭐가 잘못됐는지 좀 도와주세요 .ㅠㅠ




android.widget.CursorAdapter의 Class Overview를 보시면
"The Cursor must include a column named '_id' or this class will not work." 란 말이 있습니다.
테이블에 "_id" 필드를 "INTEGER PRIMARY KEY AUTOINCREMENT"로 추가하시고
"SELECT _id, friend FROM ..." 이런식으로 query를 만들어 보세요.