나는 소프트웨어를 실행하고하지만 난 목록보기로 스크롤 할 때, 그는 확인 표시하지만, 잠시 후 나는이 오류 메시지가 얻을 : 나는리스트 뷰에 커서를 표시하려고android.database.CursorIndexOutOfBoundsException
합니다.
내 어댑터 클래스 :
private class DBAdapter extends SimpleCursorAdapter {
private LayoutInflater mInflater;
private Cursor c;
private Context context;
내 생성자
public DBAdapter(Context context, int layout, Cursor c, String[] from, int[] to) {
super(context, layout, c, from, to);
this.c = c;
this.context = context;
mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
의 getView 방법
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if (convertView == null) {
holder = new ViewHolder();
convertView = mInflater.inflate(R.layout.match_item, null);
holder.tvHome = (TextView)convertView.findViewById(R.id.ll_home);
convertView.setTag(holder);
} else {
holder = (ViewHolder)convertView.getTag();
}
holder.tvHome.setText(c.getString(3)+"("+c.getString(6)+")");
c.moveToNext();
return convertView;
}
}
간단한보기 홀더
public static class ViewHolder {
public TextView tvHome;
}
}
어댑터 초기화
Cursor cur = dh.getAll();
startManagingCursor(cur);
String[] from = new String[] { "home" };
int[] to = new int[] { R.id.ll_home};
// Now create an array adapter and set it to display using our row
DBAdapter matches = new DBAdapter(this,R.layout.match_item, cur, from, to);
setListAdapter(matches);
누군가가이 문제를 해결하는 데 도움이 수 있습니까? 나는 모든 곳에서 검색 한하지만 난 모든 솔루션을 사용하면 이후
안부, 니 코스
이 어댑터를 인스턴스화하는 코드를 보여줄 수 있습니까? – davogotland
@ davogotland 나는 나의 초기 지위를 편집했다. 어댑터 인스턴스화는 – Nicos
에 포함되어 있습니다. getView에서 c.moveToNext()가 생기 있다고 생각합니다. 그러나 나는 확실하지 않다. 당신이 그것을 제거하면 어떻게 될까? – davogotland