我正在使用BaseAdapter
绑定自定义ListView
。我正在动态添加项目。每个项目都包含TextView
,EditText
,Spinner
。它工作正常。但现在的问题是,如果用户从Spinner
中选择任何值,请在EditText
中添加一些数据,然后如果他/她添加新项目,则会清除所有已填充数据的值。
<登记/>
因此,我想在添加新项目时阻止已添加项目的刷新。怎么做?
我的代码:
ArrayList<HashMap<String, String>> aaName = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map = null;
map = new HashMap<String, String>();
map.put("Name", Name value);
aaName.add(map);
NameAdapter nameAdapter = new NameAdapter(getActivity(), aaName);
lvName.setAdapter(nameAdapter);
public class NameAdapter extends BaseAdapter {
public View getView(int position, View convertView, ViewGroup parent) {
View vi = convertView;
if (convertView == null)
vi = inflater.inflate(R.layout.chiefcomment_view, null);
TextView tvName = (TextView) vi.findViewById(R.id.tvName);
Spinner spnTime = (Spinner) vi.findViewById(R.id.spnTime);
EditText etSpecification = (EditText) vi.findViewById(R.id.etSpecification);
HashMap<String, String> name = new HashMap<String, String>();
name = data.get(position);
tvName.setText(name.get("Name"));
// Time Spinner...
ArrayList<String> Time = new ArrayList<String>();
for (int i = 1; i <= 100; i++) {
Time.add(String.valueOf(i));
}
aaTime = new ArrayAdapter<String>(activity, R.layout.small_spinner_view, Time);
spnTime.setAdapter(aaTime);
return vi;
}
}