0
我正在使用包含两个按钮的自定义列表视图是或否当我单击否按钮时,将显示包含编辑文本的布局。列表视图中有超过15个项目。当我尝试使用TextWatcher()在第一项的编辑文本中键入并保存该值时,则该值将保存在第5个位置和第1个位置,即在第1个位置和第5个位置都保存相同的值。 我使用的代码是:在列表视图中将值设置为edittext
holder.subQuestionAnswer.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
@Override
public void afterTextChanged(Editable s) {
questionsModel.get(position).getQuestion_subquestion().get(0).setAnswer(holder.subQuestionAnswer.getText()
.toString());
Log.e("value", "no_active<>"+position+"<>"+questionsModel.get(position).getQuestion_subquestion().get(0).getAnswer().toString());
}
});
}
我怎样才能避免这种情况?
这可能是由于在ListView中回收视图。阅读本文 - http://stackoverflow.com/questions/11945563/how-listviews-recycling-mechanism-works – 2014-10-07 05:14:17
看看[这个链接](http://android.amberfog.com/?p=296)到也许明白发生了什么事。 – tibuurcio 2014-10-07 05:14:47