@SuppressLint("InflateParams")
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if(Modellist.get(position)== null){
convertView = inflater.inflate(R.layout.taklist_item,null);
holder =new ViewHolder();
holder.button2 = (Button)convertView.findViewById(R.id.tot_tv_add);
holder.view = (TextView)convertView.findViewById(R.id.tot_tv_number);
holder.view3 = (TextView)convertView.findViewById(R.id.tot_tv_price);
holder.view2 = (TextView)convertView.findViewById(R.id.tot_tv_name);
Modellist.put(position, convertView);
holder.button2.setTag(position);
convertView.setTag(holder);
}else {
convertView = Modellist.get(position);
holder= (ViewHolder)convertView.getTag();
}
holder.view2.setText(data.get(position));
holder.view3.setText(data.get(position));
holder.button2.setOnClickListener(new OnClickListener() {
private Model model;
@Override
public void onClick(View v) {
model = new Model();
model.numcount = Integer.valueOf(holder.view.getText().toString().trim())+1;
holder.view.setText(String.valueOf(model.getNumcount()));
}
});
//System.out.println("getview "+position + " convertView" + convertView);
return convertView;
}
这样写的确是可以做到数据不重复,但是会出现一个现象就是在上加载多了以后点击加号回出现界面不能刷新问题,