html中 怎么遍历listview,listview 遍历获得其中item子项数值

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,还没有被创建出来所以就会报错了!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值