I am trying to edit content in listview but when clicked to update some item, others position update also. This data are saved on SQLite database. Please see below my adapter
public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);
txtId = (TextView) v.findViewById(R.id.txtId);
txtValue = (TextView) v.findViewById(R.id.txtValue);
ckb = (CheckBox) v.findViewById(R.id.ckbEnable);
btnUpdate = (Button) v.findViewById(R.id.btnUpdate);
final String id = list.get(position).get("id").toString();
final String value= list.get(position).get("value").toString();
boolean bval = list.get(position).get("enbl").toString().equals("true") ? true : false;
txtId.setText(id);
txtValue.setText(value);
ckb.setChecked(bval);
btnUpdate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
control = new DataControl(context);
cal = new DataCal();
cal.setId(id);
cal.setValue(txtValue.getText().toString());
cal.setEnable(String.valueOf(ckb.isChecked()));
int ctrl = control.editCal(cal);
if (ctrl > 0)
MessageBox("Success on updating");
else
MessageBox("Error while updating!");
}
});
return v;