使用Android动态添加另一个项目时阻止ListView项目刷新

时间:2014-10-02 06:17:02

标签: android listview baseadapter

我正在使用BaseAdapter绑定自定义ListView。我正在动态添加项目。每个项目都包含TextViewEditTextSpinner。它工作正常。但现在的问题是,如果用户从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;
    }
}

0 个答案:

没有答案