Android基础——RecyclerView拖拽排序侧滑删除
额,关于RecyclerView就不过多的解释了,大家应该都比较了解它了,鸿洋博客有比较详细的解释:Android RecyclerView 使用完全解析 体验艺术般的控件。写本篇博客的目的就是,自己在学习的过程中想要实现该功能,想做个笔记哈,所以就有了本篇博客喽~
item布局
我们知道无论是RecyclerView还是ListView都需要item的,额……这个布局实在没什么可说的,毕竟每个人的item都不相同嘛,如下的布局代码是模仿微信的,代码如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#ffffff"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="8dp">
<ImageView
android:id="@+id/iv_icon"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@mipmap/ic_launcher" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="4dp">
<TextView
android:id="@+id/tv_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_weight="1"
android:text="李林雄"
android:textColor="#000000"
android:textSize="16dp" />
<TextView
android:id="@+id/tv_time"
android:layout_width&