이 안드로이드 뷰 리사이클 문제는 꽤 미친 짓이며, 나는 하루 종일 해결 방법을 찾으려고 노력했습니다.android list 체크 박스
이 내 코드와
public class CustomCursorAdapter extends SimpleCursorAdapter {
private Context currentContext;
private Cursor mCursor;
private boolean[] rows;
public CustomCursorAdapter(Context context, int layout, Cursor c,
String[] from, int[] to) {
super(context, layout, c, from, to);
// TODO Auto-generated constructor stub
currentContext = context;
mCursor = c;
populateRows();
}
private void populateRows() {
rows = new boolean[mCursor.getCount()];
int i = 0;
while (mCursor.moveToNext()) {
rows[i] = false;
i++;
}
}
@Override
public View getView(int position, View v, ViewGroup parent) {
// convertView.setBackgroundColor(R.drawable.darkred);
if (v != null) {
//getting checkbox
CheckBox cb = (CheckBox) v.findViewById(R.id.name);
if(rows[position]){
rows[position] = false;
}else{
rows[position] = true;
}
cb.setChecked(rows[position]);
}
return super.getView(position, v, parent);
}
}
어떤 도움이 감사를 작동하지 않는 것입니다. 여기에서 잘못
을 팽창에 의해 예를 들어, 새로운 인스턴스를 작성해야합니다. 너 뭐하려고? 작동하지 않는 것은 무엇입니까? 어떻게 작동하지 않습니까? 더 많은 정보를 제공할수록 더 나은 도움을 얻을 수 있습니다. – Gophermofur
메신저 db에서 커서를 반환하고 체크 박스의 체크 상태는 모든 db 컬럼과 관련이 없습니다. 나중에 내가 선택한 값을 db의 다른 테이블에 추가하면 그 부분이 작동합니다. 제대로 작동하지 않는 체크 박스를 선택합니다. –