4
I’m trying to get my listview retain the values placed on EditText, but every time I give one scroll I lose the data or it multiplies to other fields. Can anyone help? Follow below mine adapter:
public class WorkoutAdapter extends ArrayAdapter<Casa> {
protected Context context;
protected LinkedList<Casa> casas;
public WorkoutAdapter(Context context, LinkedList<Casa> casas){
    super(context, R.layout.exercise_layout, casas);
    this.context = context;
    this.casas = casas;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent){
    Vholder holder;
    if (convertView == null){
        convertView = LayoutInflater.from(context).inflate(R.layout.casa_layout, null);
        holder = new Vholder();
        holder.repts = (EditText)convertView.findViewById(R.id.etRepts);
        convertView.setTag(holder);
    }else{
        holder = (Vholder)convertView.getTag();
    }
    Casa current = casas.get(position);
    holder.repts.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }
        @Override
        public void afterTextChanged(Editable s) {
            current.setRepts(Integer.parseInt(s.toString()));
        }
    });
    holder.repts.setText(current.getRepts() + "");
            return convertView;
}
static class Vholder{
    EditText repts;
}
}