这是我的CursorAdapter类。 我得到滚动问题。实际上复选框正在失去他们的状态 这是我的CursorAdapter类。
public class TaskListAdapter extends CursorAdapter {
private Context context;
private TaskCursor tc;
ArrayList<Boolean> checkbox_arr = new ArrayList<Boolean>();
public TaskListAdapter(Context c, TaskCursor tc) {
super(c, tc, 0);
this.context = c;
this.tc = tc;
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
Log.d("getViewTest", "new view");
//this.context=context;
LayoutInflater li = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row = li.inflate(R.layout.task_list_item, null, false);
return row;
}
@Override
public void bindView(View v, final Context context, Cursor c) {
Log.d("valuecheck","bindviewcalled");
final Task t = tc.getTask();
CheckBox cb = (CheckBox) v.findViewById(R.id.task_checkbox);
cb.setText(t.getName());
final long id =t.getId();
final Context ctx = context;
cb.setOnCheckedChangeListener(null);
if (t.getStatus()==0) {
cb.setChecked(false);
Log.d("valuecheck","Status value =0" );
} else {
cb.setChecked(true);
Log.d("valuecheck","Status value =1" );
}
cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked) {
t.updateStatus(1,context); // Update it in Database
Log.d("valuecheck","Setting " +t.getName()+ "to status 1" );
} else {
t.updateStatus(0,context);
Log.d("valuecheck","Setting " +t.getName()+ "to status 0" );
}
}
});
}
}
我尝试过使用数组保存状态,但徒劳无功。我尝试了所有解决方案,但没有任何效果。