RecyclerView是support:recyclerview-v7中提供的控件捷枯,最低兼容到android 3.0版本晓锻。
官方介紹RecyclerView為在有限的窗口展現(xiàn)大量數(shù)據(jù)的控件。擁有類似功能的控件有ListView肩祥、GridView以及被Google遺棄的Gallery等僚匆,為毛已經(jīng)有了它們,Google還推出RecyclerView呢搭幻,那就要說說RecyclerView所具有的一些優(yōu)勢了。
那RecyclerView到底有啥優(yōu)勢呢逞盆?總結(jié)起來六顆字:低耦合高類聚檀蹋。RecyclerView已經(jīng)標(biāo)準(zhǔn)化ViewHolder,我們自定義的ViewHoler需要繼承?RecyclerView.ViewHolder云芦,然后在構(gòu)造方法中初始化控件俯逾,后面會有具體介紹。通過設(shè)置不同的LayoutManager舅逸,以及結(jié)合ItemDecoration , ItemAnimator桌肴,ItemTouchHelper,可以實現(xiàn)非常炫酷的效果琉历,這些是ListView等控件難以企及的坠七。
基本使用:
1.使用前需要在在gradle中添加依賴
`implementation?'com.android.support:recyclerview-v7:27.0.2'? `
2.編寫代碼,首先我們需要在Xml中寫RecyclerView的布局旗笔,
```
android:id="@+id/recyclerView"??
android:layout_width="match_parent"??
android:layout_height="match_parent"/>????
```
然后在activity中獲取RecyclerView彪置,并設(shè)置LayoutManager以及adapter
//通過findViewById拿到RecyclerView實例??
`mRecyclerView?=???findViewById(R.id.recyclerView);? `
//設(shè)置RecyclerView管理器??
mRecyclerView.setLayoutManager(new?LinearLayoutManager(this,?LinearLayoutManager.VERTICAL,?false));??
//初始化適配器??
mAdapter?=new?MyRecyclerViewAdapter(list);???
//設(shè)置添加或刪除item時的動畫,這里使用默認(rèn)動畫??
mRecyclerView.setItemAnimator(new?DefaultItemAnimator());??
//設(shè)置適配器??
mRecyclerView.setAdapter(mAdapter);??
下面是MyRecyclerViewAdapter的代碼:
[java]?view plain?copy
package?com.sharejoys.recyclerviewdemo.actvity;??
import?android.support.v7.widget.RecyclerView;??
import?android.view.LayoutInflater;??
import?android.view.View;??
import?android.view.ViewGroup;??
import?android.widget.TextView;??
import?com.sharejoys.recyclerviewdemo.R;??
import?java.util.List;??
/**
?*?Created?by?青青-子衿?on?2018/1/15.
?*/??
public?class?MyRecyclerViewAdapterextends?RecyclerView.Adapter?{??
private?List?list;??
public?MyAdapter(List?list)?{??
this.list?=?list;??
????}??
@Override??
public?MyAdapter.ViewHolder?onCreateViewHolder(ViewGroup?parent,?int?viewType)?{??
View?view?=?LayoutInflater.from(parent.getContext()).inflate(R.layout.item_base_use,?parent,false);??
MyAdapter.ViewHolder?viewHolder?=new?MyAdapter.ViewHolder(view);??
return?viewHolder;??
????}??
@Override??
public?void?onBindViewHolder(MyAdapter.ViewHolder?holder,?int?position)?{??
????????holder.mText.setText(list.get(position));??
????}??
@Override??
public?int?getItemCount()?{??
return?list.size();??
????}??
class?ViewHolder?extends?RecyclerView.ViewHolder?{??
????????TextView?mText;??
????????ViewHolder(View?itemView)?{??
super(itemView);??
????????????mText?=?itemView.findViewById(R.id.item_tx);??
????????}??
????}??
}??
這里item_normal的布局也非常簡單
[html]?view plain?copy
xmlns:android="http://schemas.android.com/apk/res/android"??
android:layout_width="match_content"??
android:layout_height="wrap_content"??
android:orientation="vertical">??
android:id="@+id/item_tx"??
android:layout_width="match_content"??
android:layout_height="wrap_content"??
android:gravity="center"??
android:padding="10dp"??
android:layout_gravity="center_horizontal"??
android:text="Item"/>??
然后我們運行效果如下
從例子也可以看出來蝇恶,RecyclerView的用法并不比ListView復(fù)雜拳魁,反而更靈活好用,它將數(shù)據(jù)撮弧、排列方式潘懊、數(shù)據(jù)的展示方式都分割開來,因此可定制型贿衍,自定義的形式也非常多授舟,非常靈活。
設(shè)置橫向布局:
[java]?view plain?copy
mRecyclerView.setLayoutManager(new?LinearLayoutManager(this,?LinearLayoutManager.HORIZONTAL,?false));??
設(shè)置網(wǎng)格布局:
[java]?view plain?copy
mRecyclerView.setLayoutManager(new?GridLayoutManager(this,?3));??
設(shè)置瀑布流:
[java]?view plain?copy
mRecyclerView.setLayoutManager(new?StaggeredGridLayoutManager(3,StaggeredGridLayoutManager.VERTICAL));??
如果第二個參數(shù)可以設(shè)置為橫向的舌厨,則效果如下:
從以上可知岂却,我們可以通過設(shè)置不同的管理器,實現(xiàn)不同的效果
LinearLayoutManager:以線性布局展示,可以設(shè)置橫向和縱向
GridLayoutManager:以網(wǎng)格形式展示躏哩,類似GridView效果
StaggeredGridLayoutManager:以瀑布流形式的效果
RecyclerView條目之間默認(rèn)沒有分割線署浩,那是否可以像ListView一樣設(shè)置divider以及dividerHight搞一條分割線出來呢,答案是不可以的扫尺,google并沒有提供這樣的屬性筋栋。但是谷歌為我們提供了可以定制的解決辦法,那就是以下要說ItemDecoration
利用ItemDecoration實現(xiàn)條目分割線
ItemDecoration是谷歌定義的可用于畫分割線的類正驻, 是抽象的弊攘,需要我們自己去實現(xiàn)
[java]?view plain?copy
/**
???*?An?ItemDecoration?allows?the?application?to?add?a?special?drawing?and?layout?offset
???*?to?specific?item?views?from?the?adapter's?data?set.?This?can?be?useful?for?drawing?dividers
???*?between?items,?highlights,?visual?grouping?boundaries?and?more.
???*
???*?
All?ItemDecorations?are?drawn?in?the?order?they?were?added,?before?the?item
???*?views?(in?{@link?ItemDecoration#onDraw(Canvas,?RecyclerView,?RecyclerView.State)?onDraw()}
???*?and?after?the?items?(in?{@link?ItemDecoration#onDrawOver(Canvas,?RecyclerView,
???*?RecyclerView.State)}.
???*/??
public?abstract?static?class?ItemDecoration?{??
public?void?onDraw(Canvas?c,?RecyclerView?parent,?State?state)?{??
??????????onDraw(c,?parent);??
??????}??
@Deprecated??
public?void?onDraw(Canvas?c,?RecyclerView?parent)?{??
??????}??
public?void?onDrawOver(Canvas?c,?RecyclerView?parent,?State?state)?{??
??????????onDrawOver(c,?parent);??
??????}??
@Deprecated??
public?void?onDrawOver(Canvas?c,?RecyclerView?parent)?{??
??????}??
@Deprecated??
public?void?getItemOffsets(Rect?outRect,?int?itemPosition,?RecyclerView?parent)?{??
outRect.set(0,?0,?0,?0);??
??????}??
public?void?getItemOffsets(Rect?outRect,?View?view,?RecyclerView?parent,?State?state)?{??
??????????getItemOffsets(outRect,?((LayoutParams)?view.getLayoutParams()).getViewLayoutPosition(),??
??????????????????parent);??
??????}??
??}??
當(dāng)我們通過
[java]?view plain?copy
mRecyclerView.addItemDecoration();??
??? onDraw: 該方法可以在RecyclerView的畫布上畫任何裝飾,且是在?the item views 被繪制之前回調(diào)
??? onDrawOver:該方法可以在RecyclerView的畫布上畫任何裝飾姑曙,且是在?the item views 被繪制之后回調(diào)
??? getItemOffsets :可以在該方法中為the item views添加偏移量
下面我們可以就通過繼承ItemDecoration為RecyclerView添加分割線襟交。
DividerItemDecoration的代碼如下:?
[java]?view plain?copy
package?com.sharejoys.mvpdemo.ui.customview;??
import?android.content.Context;??
import?android.content.res.TypedArray;??
import?android.graphics.Canvas;??
import?android.graphics.Rect;??
import?android.graphics.drawable.Drawable;??
import?android.support.annotation.IntDef;??
import?android.support.v4.view.ViewCompat;??
import?android.support.v7.widget.LinearLayoutManager;??
import?android.support.v7.widget.RecyclerView;??
import?android.view.View;??
/**
?*?Date:?2018/1/14
?*
?*?@author?青青-子衿
?*?@since?1.0
?*/??
public?class?DividerItemDecoration?extends?RecyclerView.ItemDecoration?{??
@OrientationType??
private?int?mOrientation?=?LinearLayoutManager.VERTICAL;??
private?Drawable?mDivider;??
private?int[]?attrs?=?new?int[]{??
????????????android.R.attr.listDivider??
????};??
public?DividerItemDecoration(Context?context,?@OrientationType?int?orientation)?{??
????????TypedArray?typedArray?=?context.obtainStyledAttributes(attrs);??
mDivider?=?typedArray.getDrawable(0);??
????????typedArray.recycle();??
????????setOrientation(orientation);??
????}??
private?void?setOrientation(@OrientationType?int?orientation)?{??
if?(orientation?!=?LinearLayoutManager.VERTICAL?&&?orientation?!=?LinearLayoutManager.HORIZONTAL)?{??
throw?new?IllegalArgumentException("傳入的布局類型不合法");??
????????}??
this.mOrientation?=?orientation;??
????}??
@Override??
public?void?onDraw(Canvas?c,?RecyclerView?parent,?RecyclerView.State?state)?{??
//調(diào)用這個繪制方法,RecyclerView會回調(diào)該繪制方法伤靠,需要我們自己去繪制條目的間隔線??
if?(mOrientation?==?LinearLayoutManager.VERTICAL)?{??
//垂直??
????????????drawVertical(c,?parent);??
}else?{??
//水平??
????????????drawHorizontal(c,?parent);??
????????}??
????}??
private?void?drawVertical(Canvas?c,?RecyclerView?parent)?{??
//?畫水平線??
int?left?=?parent.getPaddingLeft();??
int?right?=?parent.getWidth()?-?parent.getPaddingRight();??
int?childCount?=?parent.getChildCount();??
for?(int?i?=?0;?i?<?childCount;?i++)?{??
????????????View?child?=?parent.getChildAt(i);??
????????????RecyclerView.LayoutParams?params?=?(RecyclerView.LayoutParams)?child.getLayoutParams();??
int?top?=?child.getBottom()?+?params.bottomMargin?+?Math.round(ViewCompat.getTranslationY(child));??
int?bottom?=?top?+?mDivider.getIntrinsicHeight();??
????????????mDivider.setBounds(left,?top,?right,?bottom);??
????????????mDivider.draw(c);??
????????}??
????}??
private?void?drawHorizontal(Canvas?c,?RecyclerView?parent)?{??
int?top?=?parent.getPaddingTop();??
int?bottom?=?parent.getHeight()?-?parent.getPaddingBottom();??
int?childCount?=?parent.getChildCount();??
for?(int?i?=?0;?i?<?childCount;?i++)?{??
????????????View?child?=?parent.getChildAt(i);??
????????????RecyclerView.LayoutParams?params?=?(RecyclerView.LayoutParams)?child.getLayoutParams();??
int?left?=?child.getRight()?+?params.rightMargin?+?Math.round(ViewCompat.getTranslationX(child));??
int?right?=?left?+?mDivider.getIntrinsicHeight();??
????????????mDivider.setBounds(left,?top,?right,?bottom);??
????????????mDivider.draw(c);??
????????}??
????}??
@Override??
public?void?getItemOffsets(Rect?outRect,?View?view,?RecyclerView?parent,?RecyclerView.State?state)?{??
//獲得條目的偏移量(所有的條目都會回調(diào)一次該方法)??
if?(mOrientation?==?LinearLayoutManager.VERTICAL)?{??
//垂直??
outRect.set(0,?0,?0,?mDivider.getIntrinsicHeight());??
}else?{??
//水平??
outRect.set(0,?0,?mDivider.getIntrinsicWidth(),?0);??
????????}??
????}??
@IntDef({LinearLayoutManager.VERTICAL,?LinearLayoutManager.HORIZONTAL})??
public?@interface?OrientationType?{??
????}??
}??
然后在activity設(shè)置水平方向
[java]?view plain?copy
mRecyclerView.setLayoutManager(new?LinearLayoutManager(this,?LinearLayoutManager.VERTICAL,?false);???
mRecyclerView.addItemDecoration(new?DividerItemDecoration(this,?LinearLayoutManager.VERTICAL));??
豎直方向:
[java]?view plain?copy
mRecyclerView.setLayoutManager(new?LinearLayoutManager(this,?LinearLayoutManager.HORIZONAL,?false);???
mRecyclerView.addItemDecoration(new?DividerItemDecoration(this,?LinearLayoutManager.HORIZONAL))??
這里的分割線是默認(rèn)的捣域,我們可以在主題中去設(shè)置分割線的顏色
[html]?view plain?copy
@color/colorPrimary??
@color/colorPrimaryDark??
@color/colorAccent??
@drawable/bg_recyclerview_divider??
bg_recyclerview_divider.xml
[html]?view plain?copy
android:shape="rectangle">??
android:centerColor="#ff00ff00"??
android:endColor="#ff0000ff"??
android:startColor="#ffff0000"??
android:type="linear"/>??
android:width="10dp"??
android:height="10dp"/>??
運行后效果如下
以上的分割線只適用在LinearLayoutManager的相關(guān)布局中。
對于GridLayoutManager布局是不適用的宴合。需要我們單獨寫一個焕梅。
以下是對于GridLayoutManager布局的分割線代碼
[java]?view plain?copy
package?com.sharejoys.recyclerviewdemo.view;??
import?android.content.Context;??
import?android.content.res.TypedArray;??
import?android.graphics.Canvas;??
import?android.graphics.Rect;??
import?android.graphics.drawable.Drawable;??
import?android.support.v7.widget.GridLayoutManager;??
import?android.support.v7.widget.RecyclerView;??
import?android.view.View;??
/**
?*?Date:?2018/1/14?
?*
?*?@author?青青-子衿
?*?@since?1.0
?*/??
public?class?DividerGridViewItemDecoration?extends?RecyclerView.ItemDecoration?{??
private?Drawable?mDivider;??
private?int[]?attrs?=?new?int[]{??
????????????android.R.attr.listDivider};??
public?DividerGridViewItemDecoration(Context?context)?{??
????????TypedArray?typedArray?=?context.obtainStyledAttributes(attrs);??
mDivider?=?typedArray.getDrawable(0);??
????????typedArray.recycle();??
????}??
@Override??
public?void?onDraw(Canvas?c,?RecyclerView?parent,?RecyclerView.State?state)?{??
????????drawVertical(c,?parent);??
????????drawHorizontal(c,?parent);??
????}??
private?void?drawVertical(Canvas?c,?RecyclerView?parent)?{??
//繪制垂直間隔線(垂直的矩形)??
int?childCount?=?parent.getChildCount();??
for?(int?i?=?0;?i?<?childCount;?i++)?{??
????????????View?child?=?parent.getChildAt(i);??
????????????RecyclerView.LayoutParams?params?=?(RecyclerView.LayoutParams)?child.getLayoutParams();??
int?left?=?child.getRight()?+?params.rightMargin;??
int?right?=?left?+?mDivider.getIntrinsicWidth();??
int?top?=?child.getTop()?-?params.topMargin;??
int?bottom?=?child.getBottom()?+?params.bottomMargin;??
????????????mDivider.setBounds(left,?top,?right,?bottom);??
????????????mDivider.draw(c);??
????????}??
????}??
private?void?drawHorizontal(Canvas?c,?RecyclerView?parent)?{??
//繪制水平分割線??
int?childCount?=?parent.getChildCount();??
for?(int?i?=?0;?i?<?childCount;?i++)?{??
????????????View?child?=?parent.getChildAt(i);??
????????????RecyclerView.LayoutParams?params?=?(RecyclerView.LayoutParams)?child.getLayoutParams();??
int?left?=?child.getLeft()?-?params.leftMargin;??
int?right?=?child.getRight()?+?params.rightMargin?+?mDivider.getIntrinsicWidth();??
int?top?=?child.getBottom()?+?params.bottomMargin;??
int?bottom?=?top?+?mDivider.getIntrinsicHeight();??
????????????mDivider.setBounds(left,?top,?right,?bottom);??
????????????mDivider.draw(c);??
????????}??
????}??
@Override??
public?void?getItemOffsets(Rect?outRect,?View?view,?RecyclerView?parent,?RecyclerView.State?state)?{??
//?四個方向的偏移值??
int?right?=?mDivider.getIntrinsicWidth();??
int?bottom?=?mDivider.getIntrinsicHeight();??
????????RecyclerView.LayoutParams?params?=?(RecyclerView.LayoutParams)?view.getLayoutParams();??
int?itemPosition?=?params.getViewAdapterPosition();??
if?(isLastColum(itemPosition,?parent))?{??
right?=0;??
????????}??
if?(isLastRow(itemPosition,?parent))?{??
bottom?=0;??
????????}??
outRect.set(0,?0,?right,?bottom);??
????}??
/**
?????*?是否最后一行
?????*/??
private?boolean?isLastRow(int?itemPosition,?RecyclerView?parent)?{??
int?spanCount?=?getSpanCount(parent);??
if?(spanCount?!=?-1)?{??
int?childCount?=?parent.getAdapter().getItemCount();??
int?lastRowCount?=?childCount?%?spanCount;??
//最后一行的數(shù)量小于spanCount??
if?(lastRowCount?==?0?||?lastRowCount?<?spanCount)?{??
return?true;??
????????????}??
????????}??
return?false;??
????}??
/**
?????*?根據(jù)parent獲取到列數(shù)
?????*/??
private?int?getSpanCount(RecyclerView?parent)?{??
????????RecyclerView.LayoutManager?layoutManager?=?parent.getLayoutManager();??
if?(layoutManager?instanceof?GridLayoutManager)?{??
????????????GridLayoutManager?lm?=?(GridLayoutManager)?layoutManager;??
int?spanCount?=?lm.getSpanCount();??
return?spanCount;??
????????}??
return?-1;??
????}??
/**
?????*?判斷是否是最后一列
?????*/??
private?boolean?isLastColum(int?itemPosition,?RecyclerView?parent)?{??
int?spanCount?=?getSpanCount(parent);??
if?(spanCount?!=?-1)?{??
if?((itemPosition?+?1)?%?spanCount?==?0)?{??
return?true;??
????????????}??
????????}??
return?false;??
????}??
}??
我們在activity中使用該分割線
[java]?view plain?copy
mRecyclerView.setLayoutManager(new?GridLayoutManager(this,?3));??
mRecyclerView.addItemDecoration(new?DividerGridViewItemDecoration(this));??
點擊事件
RecyclerView并沒有像ListView的那樣可以設(shè)置點擊事件以及長按點擊事件,這個需要我們可以在adapter中去設(shè)置回調(diào)的方式實現(xiàn)卦洽,具體代碼如下:
MyRecyclerViewAdapter的代碼如下:
[java]?view plain?copy
package?com.sharejoys.recyclerviewdemo.actvity;??
import?android.support.v7.widget.RecyclerView;??
import?android.view.LayoutInflater;??
import?android.view.View;??
import?android.view.ViewGroup;??
import?android.widget.TextView;??
import?com.sharejoys.recyclerviewdemo.R;??
import?java.util.List;??
/**
?*?Created?by?青青-子衿?on?2018/1/15.
?*/??
public?class?MyRecyclerViewAdapter?extends?RecyclerView.Adapter?{??
private?List?list;??
private?OnItemClickListener?onItemClickListener;??
private?OnItemLongClickListener?onItemLongClickListener;??
/**
?????*?設(shè)置點擊事件
?????*/??
public?void?setOnItemClickListener(OnItemClickListener?onItemClickListener)?{??
this.onItemClickListener?=?onItemClickListener;??
????}??
/**
?????*?設(shè)置長按點擊事件
?????*/??
public?void?setOnItemLongClickListener(OnItemLongClickListener?onItemLongClickListener)?{??
this.onItemLongClickListener?=?onItemLongClickListener;??
????}??
public?MyRecyclerViewAdapter(List?list)?{??
this.list?=?list;??
????}??
@Override??
public?MyRecyclerViewAdapter.ViewHolder?onCreateViewHolder(ViewGroup?parent,?int?viewType)?{??
View?view?=?LayoutInflater.from(parent.getContext()).inflate(R.layout.item_base_use,?parent,false);??
MyRecyclerViewAdapter.ViewHolder?viewHolder?=new?MyRecyclerViewAdapter.ViewHolder(view);??
return?viewHolder;??
????}??
@Override??
public?void?onBindViewHolder(MyRecyclerViewAdapter.ViewHolder?holder,?int?position)?{??
????????holder.mText.setText(list.get(position));??
int?adapterPosition?=?holder.getAdapterPosition();??
if?(onItemClickListener?!=?null)?{??
holder.itemView.setOnClickListener(new?MyOnClickListener(position,?list.get(adapterPosition)));??
????????}??
if?(onItemLongClickListener?!=?null)?{??
holder.itemView.setOnLongClickListener(new?MyOnLongClickListener(position,?list.get(adapterPosition)));??
????????}??
????}??
@Override??
public?int?getItemCount()?{??
return?list.size();??
????}??
class?ViewHolder?extends?RecyclerView.ViewHolder?{??
????????TextView?mText;??
????????ViewHolder(View?itemView)?{??
super(itemView);??
????????????mText?=?itemView.findViewById(R.id.item_tx);??
????????}??
????}??
private?class?MyOnLongClickListener?implements?View.OnLongClickListener?{??
private?int?position;??
private?String?data;??
public?MyOnLongClickListener(int?position,?String?data)?{??
this.position?=?position;??
this.data?=?data;??
????????}??
@Override??
public?boolean?onLongClick(View?v)?{??
????????????onItemLongClickListener.onItemLongClick(v,?position,?data);??
return?true;??
????????}??
????}??
private?class?MyOnClickListener?implements?View.OnClickListener?{??
private?int?position;??
private?String?data;??
public?MyOnClickListener(int?position,?String?data)?{??
this.position?=?position;??
this.data?=?data;??
????????}??
@Override??
public?void?onClick(View?v)?{??
????????????onItemClickListener.onItemClick(v,?position,?data);??
????????}??
????}??
public?interface?OnItemClickListener?{??
void?onItemClick(View?view,?int?position,?String?data);??
????}??
public?interface?OnItemLongClickListener?{??
void?onItemLongClick(View?view,?int?position,?String?data);??
????}??
}??
activity中設(shè)置監(jiān)聽:
[java]?view plain?copy
mAdapter.setOnItemClickListener(new?MyRecyclerViewAdapter.OnItemClickListener()?{??
@Override??
public?void?onItemClick(View?view,?int?position,?String?data)?{??
Toast.makeText(MainActivity.this,?"您點擊了:??"?+?data,?Toast.LENGTH_SHORT).show();??
????????}??
????});??
mAdapter.setOnItemLongClickListener(new?MyRecyclerViewAdapter.OnItemLongClickListener()?{??
@Override??
public?void?onItemLongClick(View?view,?int?position,?String?data)?{??
Toast.makeText(MainActivity.this,?"您長按點擊了:??"?+?data,?Toast.LENGTH_SHORT).show();??
????????}??
????});??
運行后效果如下:
ItemAnimator
我們可以為RecyclerView設(shè)置增加和刪除動畫贞言,這里我們可以使用默認(rèn)動畫
[java]?view plain?copy
//設(shè)置添加或刪除item時的動畫,這里使用默認(rèn)動畫??
mRecyclerView.setItemAnimator(new?DefaultItemAnimator());??
然后在Adapter中增加刪除和添加數(shù)據(jù)的方法
[java]?view plain?copy
/**
??*?插入一條數(shù)據(jù)
??*
??*?@param?index?下標(biāo)
??*?@param?s?????數(shù)據(jù)
??*/??
public?void?addItem(int?index,?String?s)?{??
?????list.add(index,?s);??
?????notifyItemInserted(index);??
?}??
/**
??*?刪除一條數(shù)據(jù)
??*
??*?@param?index?下標(biāo)
??*/??
public?void?deleteItem(int?index)?{??
?????list.remove(index);??
?????notifyItemRemoved(index);??
?}??
activty調(diào)用刪除和添加方法后效果如下
RecycleView還有一些其他用法阀蒂,比如結(jié)合ItemTouchHelper實現(xiàn)item的拖拽效果该窗,可以自定義增加header和footer(類似Listview)
最后附上demo地址
本文來自:https://blog.csdn.net/tuike/article/details/79064750