这是我的 getView 方法:
public View getView(final int position, View convertView, final ViewGroup parent) {
ViewHolder holder;
if(convertView == null){
holder = new ViewHolder();
convertView = inflater.inflate(R.layout.propviewlistrow, null);
holder.title = (TextView) convertView.findViewById(R.id.propviewlistrow_t1);
holder.content = (EditText) convertView.findViewById(R.id.propviewlistrow_e1);
convertView.setTag(holder);
}
else{
holder = (ViewHolder)convertView.getTag();
}
holder.title.setText(names.get(position));
holder.content.setText(values.get(position));
holder.content.addTextChangedListener(new TextWatcher(){
public void afterTextChanged(Editable s) {
values.set(position, s.toString());
}
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
public void onTextChanged(CharSequence s, int start,
int before, int count) {
}
});
return convertView;
}
}
但这行不通。 edittexts 不显示正确的文本,滚动时显示的文本会切换。 下一个问题是,我在 list 中设置了 android:windowSoftInputMode="adjustPan"。 如果您单击进入最后一个编辑文本, ListView 将不会向上滚动到足以让您看到您正在键入的内容。
最佳答案
很抱歉没有直接回答您的问题,但如果我是您,我会重新设计该列表。 用户使用列表中的编辑字段将是主要的 PITA。我会做什么 - 使用长按操作并使用对话框或对话框 Activity 进行编辑,或者使用快速操作模式
http://android-developers.blogspot.com/2010/05/twitter-for-android-closer-look-at.html
关于Android:ListView 中的许多 Edittexts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3710727/