我在每一行都有listview
一个textview
和一个。edit text
如果我在一个编辑文本字段中设置一个值,然后向下滚动,我会在其他一些编辑文本字段中获得该输入字段值的重复值。我该如何解决这个问题?
我的适配器类如下所示:
public class CustomAdapter extends ArrayAdapter<String> {
private Context context;
private String[] names;
ViewHolder holder;
static class ViewHolder {
public TextView text;
public EditText editText;
}
public CustomAdapter(Context context, int textViewResourceId, String[] names) {
super(context, textViewResourceId, names);
this.context = context;
this.names = names;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.row_design, parent, false);
holder = new ViewHolder();
holder.text = (TextView) convertView.findViewById(R.id.textView1);
holder.editText = (EditText) convertView.findViewById(R.id.editText1);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
String s = names[position];
holder.text.setText(s);
return convertView;
}
}
我已经提到了这个链接: Listview duplicate action , Android listview duplicates the item on scroll