package com.zs.zs;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import java.util.ArrayList;
/**
* @Author: duke
* @DateTime: 2017-06-28 22:34
* @Description:
*/
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> {
private ArrayList<DataBean> list = new ArrayList<>();
private OnAllChangeListener listener;
public MyAdapter(ArrayList<DataBean> list) {
this.list = list;
}
public void setOnAllChangeListener(OnAllChangeListener listener) {
this.listener = listener;
}
public void update(ArrayList<DataBean> list) {
this.list = list;
notifyDataSetChanged();
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(final ViewHolder holder, final int position) {
final DataBean dataBean = this.list.get(position);
holder.checkBox.setChecked(dataBean.isChecked);
holder.checkBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dataBean.isChecked = holder.checkBox.isChecked();
checkAllStatus();
}
});
}
private void checkAllStatus() {
if (this.list == null || this.listener == null) {
return;
}
boolean status = true;
for (int i = 0; i < this.list.size(); i++) {
if (!this.list.get(i).isChecked) {
status = false;
break;
}
}
this.listener.onAllSelectOrNot(status);
}
@Override
public int getItemCount() {
if (this.list == null) {
return 0;
}
return this.list.size();
}
static class ViewHolder extends RecyclerView.ViewHolder {
private CheckBox checkBox;
public ViewHolder(View itemView) {
super(itemView);
checkBox = (CheckBox) itemView.findViewById(R.id.item_checkbox);
}
}
public interface OnAllChangeListener {
void onAllSelectOrNot(boolean selectOrNot);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Recyclerview配合activity全选按钮,数据不错乱
共77个文件
xml:40个
png:10个
bin:5个
3星 · 超过75%的资源 需积分: 32 93 下载量 185 浏览量
2017-06-28
23:21:19
上传
评论
收藏 238KB RAR 举报
温馨提示
Recyclerview配合activity全选按钮,数据不错乱 <br/> http://blog.csdn.net/fesdgasdgasdg/article/details/52069164
资源推荐
资源详情
资源评论
收起资源包目录
ZS.rar (77个子文件)
ZS
gradlew 5KB
settings.gradle 16B
.idea
libraries
support_core_ui_25_3_1.xml 582B
junit_4_12.xml 477B
appcompat_v7_25_3_1.xml 573B
javax_inject_1.xml 511B
javax_annotation_api_1_2.xml 358B
exposed_instrumentation_api_publish_0_5.xml 638B
support_annotations_25_3_1.xml 511B
constraint_layout_solver_1_0_2.xml 345B
support_fragment_25_3_1.xml 585B
hamcrest_library_1_3.xml 342B
espresso_idling_resource_2_2_2.xml 620B
support_core_utils_25_3_1.xml 591B
support_vector_drawable_25_3_1.xml 606B
support_compat_25_3_1.xml 579B
hamcrest_core_1_3.xml 526B
jsr305_2_0_1.xml 330B
animated_vector_drawable_25_3_1.xml 609B
constraint_layout_1_0_2.xml 410B
hamcrest_integration_1_3.xml 354B
support_media_compat_25_3_1.xml 597B
espresso_core_2_2_2.xml 587B
recyclerview_v7_25_3_1.xml 582B
rules_0_5.xml 548B
javawriter_2_1_1.xml 330B
support_v4_25_3_1.xml 404B
runner_0_5.xml 551B
runConfigurations.xml 564B
misc.xml 2KB
compiler.xml 686B
workspace.xml 170KB
gradle.xml 626B
encodings.xml 159B
modules.xml 341B
copyright
profiles_settings.xml 76B
gradle
wrapper
gradle-wrapper.properties 236B
gradle-wrapper.jar 52KB
.gradle
3.3
tasks
_app_compileDebugJavaWithJavac
localJarClasspathSnapshot
localJarClasspathSnapshot.bin 20KB
localJarClasspathSnapshot.lock 17B
localClassSetAnalysis
localClassSetAnalysis.bin 28KB
localClassSetAnalysis.lock 17B
taskArtifacts
fileHashes.bin 134KB
taskArtifacts.bin 67KB
fileSnapshots.bin 1.38MB
taskArtifacts.lock 17B
local.properties 435B
ZS.iml 856B
gradlew.bat 2KB
gradle.properties 747B
.gitignore 127B
app
src
androidTest
java
com
zs
zs
ExampleInstrumentedTest.java 748B
test
java
com
zs
zs
ExampleUnitTest.java 403B
main
AndroidManifest.xml 723B
res
mipmap-hdpi
ic_launcher.png 3KB
ic_launcher_round.png 4KB
mipmap-xxxhdpi
ic_launcher.png 10KB
ic_launcher_round.png 14KB
mipmap-xhdpi
ic_launcher.png 5KB
ic_launcher_round.png 6KB
mipmap-mdpi
ic_launcher.png 2KB
ic_launcher_round.png 2KB
drawable
layout
item.xml 676B
activity_main.xml 630B
values
colors.xml 214B
strings.xml 68B
styles.xml 394B
mipmap-xxhdpi
ic_launcher.png 8KB
ic_launcher_round.png 10KB
java
com
zs
zs
MyAdapter.java 2KB
MainActivity.java 2KB
DataBean.java 159B
libs
app.iml 10KB
.gitignore 8B
build.gradle 1014B
proguard-rules.pro 949B
build.gradle 521B
共 77 条
- 1
资源评论
- 男儿当自强-2019-04-17资源还可以
- qq_342114922017-11-04资源还可以
- IT的鱼2017-11-02很好很不错哦
- 志尊宝2018-04-12这个链接上的资源好像不付,自己没用到
android阿杜
- 粉丝: 424
- 资源: 32
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 《CKA/CKAD应试指南/从docker到kubernetes 完全攻略》学习笔记 第1章docker基础(1.1-1.4)
- 基于python实现的水下压缩空气储能互补系统建模仿真与经济效益分析+源代码+论文
- 华中科技大学-自然语言处理实验,Bi-LSTM+CRF的中文分词框架,并且利用基于深度学习的方法进行中文命名实体识别++源码报告
- 基于动态罚函数的铁路车流分配与径路优化模型python源码
- 鱼群算法求解组环问题python源码+文档说明
- 基于决策优化的多波束测深测线规划模型MATLAB代码
- 课程设计-基于python实现的多目标优化算法求解带时间窗的车辆路径规划问题+源代码+文档说明+界面截图+pptx
- 基于通信信号与通信系统的MATLAB仿真源码-课程设计
- 嵌入式-信号机制(概念,发送,定时,捕捉,SIGCHLD 信号实现回收子进程)
- c语言管理系统大一大二笔记
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功