您的位置:首页 > 其它

pulltorefreshlistview 和xlistview 中的获取item控件布局时出现的类转换异常的问题:

2016-04-26 20:38 543 查看
pulltorefreshlistview 和xlistview 中的出现的类转换异常的问题在于

这两个listview都有头部和尾部在获取listview的子布局的时候应该这样:

//全选操作

public void selectAll(){

System.out.println("gouwucheactivity中的count----"+listView.getChildCount());

for (int index = 1; index < listView.getChildCount()-1; index++) {

RelativeLayout layout = (RelativeLayout) listView.getChildAt(index);

// RelativeLayout layout = (RelativeLayout) ptr_listView.getChildAt(index);

// 04-05 17:31:20.632: E/AndroidRuntime(28214): java.lang.ClassCastException: com.library.listview.XListViewHeader cannot be cast to android.widget.RelativeLayout

CheckBox checkBox = (CheckBox) layout.findViewById(R.id.check_gouwu_select);

// CheckBox check_top = (CheckBox) layout.findViewById(R.id.check_gouwu_select1);

checkBox.setChecked(true);

// check_top.setChecked(true);

System.out.println("gouwucheactivity在购物车的selectAll方法中调用了");

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: