@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ViewHolder viewHolder;
final Item item = getItem(position);
View view = null;
convertView = null;
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.godown_list_iemname_activity, parent, false);
viewHolder = new ViewHolder();
viewHolder.text = (TextView) convertView
.findViewById(R.id.list_label_name);
viewHolder.edit = (EditText) convertView
.findViewById(R.id.qty_editText);
viewHolder.text_id = (TextView) convertView
.findViewById(R.id.list_label_qty);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
// Populate the data into the template view using the data object
viewHolder.text.setText(itemlist.get(position).getId());
viewHolder.edit.setText(itemlist.get(position).getQty());
viewHolder.text_id.setText(itemlist.get(position).getItemcode());
viewHolder.edit.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) {
sb = new StringBuilder(s.length());
sb.append(s);
viewHolder.edit.setTextColor(Color.RED);
String ts =String.valueOf(viewHolder.text.getText()) +"_"+sb.toString();
value.add(ts);
System.out.println("array list size1"+value.size());
System.out.println("array list size1"+value);
SharedPreferences pref = getContext().getSharedPreferences("MyPref", MODE_PRIVATE);
SharedPreferences.Editor editor = pref.edit();
editor.putString("Value", String.valueOf(value));
editor.clear();
editor.commit();
}
@Override
public void afterTextChanged(Editable s) {
}
});
value.clear();
System.out.println("array list size"+ value);
return convertView;
}
当我滚动列表时,我的编辑文本值被删除..实际上我从数据库中获取所有值,如果我想更改编辑文本值,在我滚动列表后,我的更改值被删除....我尝试了很多方法....我得到任何答案....如果有人知道,你能解决我的问题...我想将我编辑的值存储在单独的数组中,并在按下更新按钮时再次发送到后端。 ....