리스트뷰에 Cursor로 받은 정보를 띄워주려고 합니다.
리스트뷰의 각 행은 이미지뷰와 텍스트뷰를 담고있습니다. 각 정보는 CursorAdapter로 상속 받은 클래스에서 newView와 bindView로 이어줬구요..
처음엔 제가 원하던 바대로 출력이 되나 싶더니, DB에 정보 추가 가능한 리스너가 있어서 Item갯수가 많아지면
Item7이 넘어갈때 뷰를 터치(클릭)할때마다 기이하게 변동되는데요 ;;
Item1
Item2
Item3
Item4
...
...
@Override
public void bindView(View view, Context context, Cursor cursor) {
c = cursor;
String cursor_text1 = c.getString(c.getColumnIndex(DbHelper.TITLE));
String cursor_text2 = c.getString(c.getColumnIndex(DbHelper.BODY));
String cursor_text3 = c.getString(c.getColumnIndex(DbHelper.DATE));
String cursor_img = c.getString(c.getColumnIndex(DbHelper.IMAGESRC));
text1.setText(cursor_text1);
text2.setText(cursor_text2);
text3.setText(cursor_text3);
BitmapFactory.Options bo = new BitmapFactory.Options();
bo.inSampleSize = 8;
Bitmap bm = BitmapFactory.decodeFile(cursor_img, bo);
imgview.setImageBitmap(bm);
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
c = cursor;
LayoutInflater inflater = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.listrow, null);
text1 = (TextView) v.findViewById(R.id.textview1);
text2 = (TextView) v.findViewById(R.id.textview2);
text3 = (TextView) v.findViewById(R.id.textview3);
imgview = (ImageView) v.findViewById(R.id.imageview1);
return v;
}
}
CursorAdapter 상속없이 SimpleCursorAdapter를 이용해서 text만 출력시켰을땐 아무 이상없었는데..
이미지뷰 출력때문에 할 수 없이 CursorAdapter를 상속받아서 구현해본건데 이런 오류 투성이네요 ㅠ_ㅠ
작은 실마리라도 부탁드립니다. 꼭 해결하고 싶어요
app 재시작시 정상 추가되는 문제는 데이터 추가후 리스트뷰를 리프레쉬 안해줘서 그런거 같은데요
cursorAdapter쪽은 확실히 모르겠으나 일반적으로 adapter에서는 notificationChange인가요 그걸 써주죠? 아마도,.
그리고 삭제가 엉뚱한게 된다는 것은 실제로 엉뚱한 값을 줘서 삭제된거일거같은데 삭제 키값이라해야하나요 그게 잘못 들어간거 일거같은데 그쪽부분 로그를 찍어보시는게... 아니면 말구요..
text2 = (TextView) v.findViewById(R.id.textview2);
text3 = (TextView) v.findViewById(R.id.textview3);
imgview = (ImageView) v.findViewById(R.id.imageview1);
이 부분이 bindView쪽으로 옮겨가거나
ViewHolder라는 것을 쓰는 방식이 있는데요. APIDemo잘 찾아보시고 응용하시기 바랍니다.




bitmap decodeFile이 과부하 연산이기때문에 bindView에 넣는건 적절하지 않아보이긴 하지만...
말씀 하신 증상의 원인으로는 안보이네요.
query를 어떻게 날리셨는지를 봐야 할것 같습니다.
Adapter 초기화 하는 부분의 소스도 볼 수 있을까요?