private List>getSelectValues(String ZTstr){
List> mList =new ArrayList>();
List> mList1 =new ArrayList>();
int type2 = 2;
int type1 = 1;
if ("0".equals(ZTstr)) {
for(int i = 0;i
HashMap map = new HashMap();
map.put("XCXTRID", list.get(i).get("SSXCSJBID").toString());
map.put("XCXRESULT", type1);
map.put("XCXCAPTION","");
mList.add(map);
}
for(int j = 0;j
LinearLayout layout = (LinearLayout)aqsc_rcxc_listview.getChildAt(j);
CheckBox bCheckBox = (CheckBox)layout.findViewById(R.id.aqsc_rcxc_item_checkbox);
EditText text = (EditText)layout.findViewById(R.id.aqsc_rcxc_edittext);
if (bCheckBox.isChecked()) {
HashMap map = new HashMap();
map.put("XCXTRID", list.get(j).get("SSXCSJBID").toString());
map.put("XCXRESULT", type2); //检查项中按钮选中的默认为不达标
map.put("XCXCAPTION",text.getText().toString()); //检查结果描述为可选填数据
mList1.add(map);
mList.remove(j);
}
}
mList.addAll(mList1);
return mList;
}
return null;
}
listview.getChildCount();方法这里获得的长度值;是当前adapter 显示出的子项view的个数;简单说就是:
Madapter madapter = new Madapter(this,mlist);
listview .setAdapter(madapter);
其中 mlist 的长度,代表listview总共有多长,但是当你加载到当前界面显示时,大多数情况下,屏幕上并不能完全显示其所有listview的长度,所以 listview.getChildCount()的长度为当前页面加载出来的所有的view的长度,当你上下滑动把所有数据都加载出来时,listview.getChildCount() = list.size()=listview.getcount()
其中:ListView.getCount()(实际上是 AdapterView.getCount()) 返回的是其 Adapter.getCount() 返回的, 也就是“所包含的 Item 总个数”。
ListView.getChildCount()(ViewGroup.getChildCount) 返回的是显示层面上的“所包含的子 View 个数”。
当 ListView 中的 Item 比较少无需滚动即可全部显示时,二者是等价的;当 Item 个数较多需要滚动才能浏览全部的话, getChildCount() < getCount()
其中 getChildCount() 返回的是当前可见的 Item 个数
所以当你有时候遍历 ListView.getChildCount() 或报错也就知道其中原因了吧,因为你所遍历的那个item 所在的view,还没有被创建出来所以就会报错了!