效果图如下:
Recyclerview 实现多选,单选,全选,反选,批量删除的步骤
1.在Recyclerview布局中添加上底部的全选和反选按钮,删除按钮,和计算数量等控件
2.这里选中的控件没有用checkbox来做,用的是imageview,选中和不选中其实是两张图片
3.默认是不显示选中的控件的,点击编辑的时候显示,点击取消的时候隐藏
4.通过adapter和activity数据之间的传递,然后进行具体的操作
具体代码如下:
在recyclerview的布局中写全选,反选,删除,计数等相应的控件
android:id="@+id/ll_mycollection_bottom_dialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="bottom"
android:visibility="gone"
android:background="@color/app_bg">
android:background="#e5e5e5"
android:layout_width="match_parent"
android:layout_height="1px"/>
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="@dimen/px_90">
android:layout_centerVertical="true"
android:id="@+id/tv"
android:textColor="#1A1A1A"
android:textSize="@dimen/px_28"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/px_30"
android:text="@string/mine_certify_select" />
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/tv"