android如何实现ListView中的CheckBox的全选、反选、全不选
来源:互联网 发布:东海村核事故 知乎 编辑:程序博客网 时间:2024/06/06 00:54
转发地址:http://blog.163.com/hjl_love_lx/blog/static/1209689902011723101742679/
1、全选
for (int index = 0; index < controlActionView.getChildCount(); index++) {LinearLayout layout = (LinearLayout) controlActionView.getChildAt(index);
CheckBox checkBox = (CheckBox) layout.findViewById(R.id.isselected);
checkBox.setChecked(true);
}
2、反选
for (int index = 0; index < controlActionView.getChildCount(); index++) {
LinearLayout layout = (LinearLayout) controlActionView.getChildAt(index);
CheckBox checkBox = (CheckBox) layout.findViewById(R.id.isselected);
if (checkBox.isChecked()) {
checkBox.setChecked(false);
} else {
checkBox.setChecked(true);
}
}
3、全不选
for (int index = 0; index < controlActionView.getChildCount(); index++) {
LinearLayout layout = (LinearLayout) controlActionView.getChildAt(index);
CheckBox checkBox = (CheckBox) layout.findViewById(R.id.isselected);
checkBox.setChecked(false);
}
看了上面的代码是不是很简单呢,其实知识都这样,编程更是如此。在遇到问题时,感觉这个问题是多么的深不可测。然后通过各种方式去查找资料解决问题。当我们找到解决方案时,感觉都很简单。该ListView中的布局文件如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
androidrientation="horizontal"
android:layout_height="match_parent">
<TextView
android:id="@+id/controlaction_id"
android:layout_height="0dip"
android:layout_width="0dip"
/>
<TextView
android:id="@+id/controlaction_code"
android:layout_width="180dip"
android:layout_height="wrap_content"
android:textSize="15pt"
/>
<TextView
android:id="@+id/controlaction_name"
android:layout_height="wrap_content"
android:layout_width="180dip"
android:textSize="8pt"
/>
<CheckBox
android:id="@+id/isselected"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
0 0
- android如何实现ListView中的CheckBox的全选、反选、全不选
- android如何实现ListView中的CheckBox的全选、反选、全不选
- android如何实现ListView中的CheckBox的全选、反选、全不选
- ListView中的CheckBox全选反选
- ListView+CheckBox实现全选和反选
- 带checkbox的listView 实现多选,全选,反选
- checkbox的listView实现多选,全选,反选
- checkbox的listView 实现多选,全选,反选
- 实现listview中checkbox的全选、反选和取消
- 如何实现listView中checkbox的全选与反选功能
- ListView和CheckBox实现全选,全不选和反选
- Android 带checkbox的listView 实现多选,全选,反选
- Android 带checkbox的listView 实现多选,全选,反选
- Android 带checkbox的listView 实现多选,全选,反选
- Android 带checkbox的listView 实现多选,全选,反选
- Android 带checkbox的listView 实现多选,全选,反选
- Android 带checkbox的listView 实现多选,全选,反选
- Android 带checkbox的listView 实现多选,全选,反选
- Android 以jar包方式共享资源注意事项
- 基于PCE的SDN演进方式
- 自己整理的东西(onenote)
- Python魔术方法
- Mybatis极其(最)简(好)单(用)的一个分页插件
- android如何实现ListView中的CheckBox的全选、反选、全不选
- Ubuntu 配置 python环境 和 mxnet
- js中opener与parent的区别详细解析
- Get paramter
- iOS内存那点事儿
- Arcgis Engine的拓扑检查类
- AngularJS+ASP.NET MVC+SignalR实现消息推送
- oracle10g 数据库导入dmp数据
- c++中string 的replace用法