我有ListView
,我使用EditText
和Button
创建了一个布局,问题是当我在列表的第一项中写入时,自动列表的最后一项设置相同的信息。我在我的ViewHolder
适配器中使用。
我的适配器示例:
public View getView(int position, View view, ViewGroup parent) {
final ViewHolder holder;
if (view == null){
LayoutInflater layoutInflater = LayoutInflater.from(context);
view = layoutInflater.inflate(R.layout.lst_autocomplete, parent, false);
holder = new ViewHolder();
holder.direction = (AutoCompleteTextView) view.findViewById(R.id.autoComplete);
holder.information= (TextView) view.findViewById(R.id.txtInformation);
holder.tag = (EditText) view.findViewById(R.id.txtTag);
holder.check= (CheckBox) view.findViewById(R.id.chkCheck);
holder.product = (EditText) view.findViewById(R.id.txtProduct);
view.setTag(holder);
}else{
holder = (ViewHolder) view.getTag();
}
CustomAdapter adapter = new CustomAdapter(context, cutom_list.lst_product);
holder.direction.setAdapter(adapter);
holder.direction.setThreshold(1);
holder.direction.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Global list= (Global) parent.getItemAtPosition(position);
holder.direction.setText(list.getDesc());
holder.information.setText(list.getUbi());
}
});