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方法中调用了");
}
}
这两个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方法中调用了");
}
}
相关文章推荐
- 程序集反射 Type 类
- 网络通信 --> Socket、TCP/IP、HTTP、FTP及网络编程
- 关于色温调节的一个 shader
- C经典 输入数组并打印
- C++小细节之static的作用
- 数据结构之排序算法实现(选自大话数据结构)
- 数据库设计三大范式
- QDockWidget嵌套布局详解-实现Visual Studio布局
- 01_DllZZ.cpp
- 手机禁止缩放网页 手机CSS导入
- 使用spark读取es中的数据并进行数据清洗,使用fp-growth算法进行加工
- Ubuntu Intellij IDEA 配置
- c++实验4——项目七——百钱百鸡问题
- 栈——算术表达式
- C++第4次实验
- Fragment not attached to activity 异常
- java中使用反射往一个泛型是Integer类型的ArrayList中添加字符串,反射的案例1.
- 第九周
- 背景图片自适应分辨率浏览器大小自动拉伸全屏代码
- [翻译]现代java开发指南 第二部分