小应用2.(listview单个Item点击时防止其他的跟随变化
2017-08-10 本文已影响0人
谜之龙
在ListView的适配器(adpter)里加代码,并且防止复用所产生的重复
HashMap<Integer,View> Imap = new HashMap<Integer,View>();
public View getView(int position, View convertView, ViewGroup parent) {
viewholder holder=null;
if (Imap.get(position)==null){
convertView= LayoutInflater.from(parent.getContext()).inflate(R.layout.choose_pick_item,null);
holder=new viewholder(convertView);
final int p = position;
Imap.put(position, convertView);
convertView.setTag(holder);
}else {
convertView=Imap.get(position);
holder= (viewholder) convertView.getTag();
}
final CustomEntity entity=data.get(position);
holder.namenumber.setText(entity.getNamenumber());
holder.data.setText(entity.getData());
holder.location.setText(entity.getLoad());
holder.tel.setText(entity.getTel());
return holder.convertView;
}