BaseQuickAdapter,继承子 RecyclerView.Adapter
public class QuickAdapter extends BaseQuickAdapter,BaseViewHolder> { public QuickAdapter() { super(R.layout.view_list_item); } @Override protected void convert(BaseViewHolder helper, RecyclerItem item) { helper.setText(R.id.list_item_title_tv,item.getTitle()) .setText(R.id.list_item_content_tv,item.getContent()); helper.getView(R.id.list_item_content_tv).setSelected(true); } }
关于初始化
public BaseQuickAdapter(int layoutResId, List<T> data)
public BaseQuickAdapter(List<T> data)
public BaseQuickAdapter(int layoutResId)
关于动画效果
quickAdapter.openLoadAnimation();
(1)默认五种动画
ALPHAIN:渐显;SCALEIN:缩放;SLIDEIN_BOTTOM:从下到上;
SLIDEIN_LIFT:从左到右;SLIDEIN_RIGHT:从右到左
quickAdapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_RIGHT);
public void setDuration(int duration)
(2)自定义动画
quickAdapter.openLoadAnimation(new BaseAnimation() { @Override public Animator[] getAnimators(View view) { return new Animator[]{ ObjectAnimator.ofFloat(view,"scaleY",0.3f,5f,1), ObjectAnimator.ofFloat(view,"scaleX",0.3f,8f,1), ObjectAnimator.ofFloat(view,"rotation",1,60,0) }; } });
(3)是否只是第一次显示动画效果
public void isFirstOnly(boolean firstOnly)
关于数据的加载或删除
(1)设置初始化数据
public void setNewData(List<T> data)
(2)加入新数据
public void addData(T data)
(3)在指定位置加入数据
public void addData(int position, T data)
(4)批量加入数据
public void addData(List<T> newData)
(5)在指定位置批量加入数据
public void addData(int position, List<T> data)
(6)更新指定位置的数据
public void setData(int index, T data)
(7)移除指定位置的数据
public void remove(int position)
(8)获得当前列表数据
public List<T> getData()
(9)获得指定位置的数据
public T getItem(int position)
(10)获得列表数据的数量
public int getItemCount()
关于上拉刷新
public void setOnLoadMoreListener(RequestLoadMoreListener requestLoadMoreListener)
quickAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() { @Override public void onLoadMoreRequested() { recyclerView.postDelayed(new Runnable() { @Override public void run() { } },500); } });
自定义底部加载视图
public void setLoadMoreView(LoadMoreView loadingView)
(1)判断是否正在加载状态
public boolean isLoading()
(2)设置加载完毕或着没有更多的数据了
public void loadMoreEnd()
public void loadMoreEnd(boolean gone)
public void loadMoreComplete()
(3)加载失败
public void loadMoreFail()
(4)设置加载状态(true:显示加载效果;false:不显示加载效果)
public void setEnableLoadMore(boolean enable)
public boolean isLoadMoreEnable()
关于头部和尾部
(1)加入头部
public void addHeaderView(View header)
public void addHeaderView(View header, int index)
public void addHeaderView(View header, int index, int orientation)
(2)加入尾部
public void addFooterView(View footer)
public void addFooterView(View footer, int index)
public void addFooterView(View footer, int index, int orientation)
(3)更新头部
public void setHeaderView(View header)
public void setHeaderView(View header, int index)
public void setHeaderView(View header, int index, int orientation)
(4)更新尾部
public void setFooterView(View header)
public void setFooterView(View header, int index)
public void setFooterView(View header, int index, int orientation)
(5)移除头部
public void removeHeaderView(View header)
public void removeAllHeaderView()
(6)移除尾部
public void removeFooterView(View footer)
public void removeAllFooterView()
关于空视图
(1)自定义空视图
public void setEmptyView(int layoutResId, ViewGroup viewGroup)
public void setEmptyView(View emptyView)
(2)空视图的相关设置
头部跟列表相关
public void setHeaderAndEmpty(boolean isHeadAndEmpty)
头部尾部跟列表相关
public void setHeaderFooterEmpty(boolean isHeadAndEmpty, boolean isFootAndEmpty)
设置是否使用空视图
public void isUseEmpty(boolean isUseEmpty)
获得空视图
public View getEmptyView()
可扩展功能(后续说明)