SmartRecycleView的使用

一、优势:

1.1,提供上拉刷新与下拉加载的封装;

1.2,提供Head布局;

1.3,提供一个SmartRecycleView多种布局、多种Grid布局、Grid不规则布局。


二、SmartRecycleView的使用

2.1,引入SmartRecycleView,可选择依赖第三方或者配置远程仓库

Gradle Dependency Add this in your root build.gradle file (not your module build.gradle file):

allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}

2.2,xml中引入

<me.zuichu.recyclerview.view.SmartRecyclerview
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
2.3,Activity中设置布局管理器

//设置布局管理器
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
recyclerview.setLayoutManager(linearLayoutManager);
2.4,Activity中设置Adapter

//设置Adapter
mainAdapter = new MainAdapter(this, list);
recyclerview.setAdapter(mainAdapter);
2.5,Activity中设置监听事件

//设置监听事件
mainAdapter.setOnItemClickListener(this);
mainAdapter.setOnItemLongClickListener(this);
recyclerview.setLoadingListener(this);
2.6,Activity中实现SmartRecycleView提供的接口

implements SmartRecyclerview.LoadingListener,BaseSmartAdapter.OnRecyclerViewItemClickListener, BaseSmartAdapter.OnRecyclerViewItemLongClickListener
2.7,SmartRecycleView提供了对外方法

//SmartRecycleView对外提供的方法
recyclerview.refresh(); //刷新完成,要使用
recyclerview.loadMoreComplete();    //加载更多完成,要使用
recyclerview.setNoMore(true);   //没有更多数据了,要使用
recyclerview.setRefreshProgressStyle(ProgressStyle.BallBeat);   //可以自己设置更改刷新和加载更多的样式
recyclerview.setLoadingMoreProgressStyle(ProgressStyle.BallClipRotate);
recyclerview.setArrowImageView(R.mipmap.ic_pulltorefresh_arrow);    //可以自己设置更改刷新的箭头,不设置的话为默认
2.8,其中Adapter根据需要,这里选择继承 BaseSmartAdapter<String>

class MainAdapter extends BaseSmartAdapter<String> {
    public MainAdapter(Context context, List<String> lists) {
        super(context,R.layout.item_main, lists);
    }

    @Override
    public void bindData(SmarViewHolder smarViewHolder, String s) {

    }
}
参考地址:https://github.com/zuichu/SmartRecyclerView
猛戳这里下载demo

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

流星雨在线

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值