안녕하세요. 지금 커스텀 뷰와 DB를 연동하면서 갈피를 잡지 못해 질문드립니다.
지금 DB연동을 통해 커스텀 리스트뷰를 통해 DB의 값을 긁어오는데 까지는 했는데
하다보니 DB를 반복문을 사용해 긁어 왔는데 이미지를 리스트뷰 왼쪽에 넣을려고 하는데 어떻게 넣어야 하나요?
반복문을 사용하다 보니 XML에서 이미지를 하나만 넣어두면 넣어둔 이미지만 출력이 되니..
방법을 잘 모르겠습니다. 알려주시면 감사하겠습니다.
소스 부분적으로 올립니다.
/**************************DB 긁어 와서 리스트에 넣는 부분**********************************/
do {
if (mCursor != null && !(mCursor.isAfterLast())) {
DataVO tmp = new DataVO();
tmp.setName(mCursor.getString(2));
tmp.setType(mCursor.getString(1));
tmp.setImage(mCursor.getInt(6));
String phone = "";
try {
phone = mCursor.getString(5);
tmp.setTel(mCursor.getString(5));
} catch (Exception e) {
tmp.setTel("");
}
tmp.setInfo(mCursor.getString(3));
tmp.setAddr(mCursor.getString(4));
CourseList.add(new DataVO(tmp));
}
} while (mCursor.moveToNext());
mCursor.close();
CustomListAdapter locListAdapter = new CustomListAdapter(this,
R.layout.row, CourseList);
/* * * * * * * * * * * * * * * * * * * * 커스텀어댑터 정의 * * * * * * * * * * * * * * * * * * * * * * * * */
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater li = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = li.inflate(R.layout.row, null);
}
/* position은 리스트가 위치한 상대값 (0부터 시작해서 증가) */
DataVO locdata = (DataVO) locArray.get(position);
if (locdata != null) {
TextView locname = (TextView) v.findViewById(R.id.name);
TextView locaddress = (TextView) v.findViewById(R.id.address);
ImageView thumbimg = (ImageView) v.findViewById(R.id.image);
if (thumbimg != null) { //
thumbimg.setBackgroundResource(locdata.getImage());
}
if (locname != null) { // 장소이름 표시
locname.setText(locdata.getName());
}
if (locaddress != null) {// 주소 받아 오기
locaddress.setText(locdata.getTel() + ","
+ locdata.getType());
}
}
return v;
}
/**********************************************************************/
당연히 XML에는 커스텀뷰로 이미지뷰 하나 있습니다.
방법좀 알려주세요 이미지를 어떻게 반복문을 돌리면서 넣을 수 있을까요?ㅜ