标签:style class blog code ext color
1、listview的getcount与getchildcount,getcount>=getchildcount.getcount为所有的listdata的size值,getchildcount获得的是显示的值;
当itemsize<=显示屏的显示数量,getcount()=getchildcount(),
当itemsize >显示屏的显示数量,getcount> getchildcount;
2、问题原因:
1 List<Integer> checkPosition = new ArrayList<Integer>();//记住状态 2 3 //重写getview() 4 5 6 @Override 7 public View getView(final int position, View convertView, ViewGroup parent) { 8 // TODO Auto-generated method stub 9 View rowView = convertView; 10 ViewHolder holder = null; 11 if (rowView == null) { 12 holder = new ViewHolder(); 13 rowView = mInflater.inflate(R.layout.item_autoresult_list, null); 14 holder.cb_auto_check = (CheckBox) rowView 15 .findViewById(R.id.cb_auto_check); 16 17 rowView.setTag(holder); 18 } else { 19 holder = (ViewHolder) rowView.getTag(); 20 } 21 holder.cb_auto_check.setText(mList.get(position).getName()); 22 23 24 holder.cb_auto_check.setTag(new Integer(position)); 25 26 27 if (checkPosition != null) { 28 holder.cb_auto_check.setChecked((checkPosition 29 .contains(new Integer(position)) ? true : false)); 30 } else { 31 holder.cb_auto_check.setChecked(false); 32 } 33 34 final CheckBox finalholder = holder.cb_auto_check; 35 holder.cb_auto_check 36 .setOnCheckedChangeListener(new OnCheckedChangeListener() { 37 38 @Override 39 public void onCheckedChanged(CompoundButton buttonView, 40 boolean isChecked) { 41 // TODO Auto-generated method stub 42 System.out.println("finalholder.getTag()" 43 + finalholder.getTag()); 44 if (isChecked) { 45 if (!checkPosition.contains(finalholder.getTag())) { 46 System.out.println("true+contains" 47 + finalholder.getTag()); 48 checkPosition.add((Integer) finalholder 49 .getTag()); 50 } 51 } else { 52 if (checkPosition.contains(finalholder.getTag())) { 53 System.out.println("fasle+contains" 54 + finalholder.getTag()); 55 checkPosition.remove(finalholder.getTag()); 56 } 57 } 58 } 59 }); 60 return rowView; 61 }
OnCheckedChangeListener change = new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // TODO Auto-generated method stub if(isChecked){ for(int i=0;i<billall.size();i++){ LinearLayout layout = (LinearLayout)listView.getChildAt(i); ImageView checkView = (ImageView)layout.findViewById(R.id.check); checkView.setImageResource(R.drawable.orders_sign); } } else{ for(int i=0;i<billall.size();i++){ LinearLayout layout = (LinearLayout)listView.getChildAt(i); ImageView checkView = (ImageView)layout.findViewById(R.id.check); checkView.setImageResource(R.drawable.orders_choose); } } } };
解决 listview的item超过屏幕显示出现滚动的全选问题,布布扣,bubuko.com
解决 listview的item超过屏幕显示出现滚动的全选问题
标签:style class blog code ext color
原文地址:http://www.cnblogs.com/zust-zbt/p/3794967.html