My problem is very similar than this post . In each row of my ListView, I have a flag with a listener. List of update database for the listener.
@Override public void bindView(View v, Context context, Cursor c) { TextView tvA = (TextView) v.findViewById(R.id.adi_tv_activity); CheckBox cb = (CheckBox) v.findViewById(R.id.adi_cbox); tvA.setText(c.getString(c.getColumnIndex("name"))); final long id = c.getLong(c.getColumnIndex("_id")); final Context ctx = context; cb.setOnCheckedChangeListener(new OnCheckedChangeListener(){ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { ObjDBF dbf = new ObjDBF(ctx);
I have 2 problems.
- Scrolling issue. Moving the list I have lost the state of the check box for a line that disappears from the screen.
- Anytime I use setChecked, the called listenr invokes a new db update.
To solve the scrolling problem, I wanted to use adapter.changeCursor every time I update db, but for the second problem, it causes a loop.
I am also trying to use an Array array, as in the second answer of the above message, but it uses the getView od adapter method, I have cursorAdapter and work in newView and bindView
How can i solve the problem?
edit: auselen solution works, but it creates and destroys many listeners, is there another more efficient solution?
source share