private void initView() { superRecyclerView = (SuperRecyclerView) findViewById(R.id.super_recycle_view); LinearLayoutManager layoutManager = new LinearLayoutManager(this); layoutManager.setOrientation(LinearLayoutManager.VERTICAL); superRecyclerView.setLayoutManager(layoutManager); superRecyclerView.setRefreshEnabled(true); // 可以定制是否开启下拉刷新 superRecyclerView.setLoadingMoreEnabled(true); // 可以定制是否开启加载更多 superRecyclerView.setLoadingListener(this); // 下拉刷新,上拉加载的监听 superRecyclerView.setRefreshProgressStyle(ProgressStyle.BallSpinFadeLoader); // 下拉刷新的样式 superRecyclerView.setLoadingMoreProgressStyle(ProgressStyle.BallClipRotate); // 上拉加载的样式 superRecyclerView.setArrowImageView(R.mipmap.iconfont_downgrey); // 设置下拉箭头 }
@Override public void onLoadMore() { if (dataList.size() >= 50) { superRecyclerView.setNoMore(true); return; } new Handler() .postDelayed( new Runnable() { @Override public void run() { tempList.clear(); tempList = getDataList(20); dataList.addAll(tempList); superRecyclerView.completeLoadMore(); } }, 3000); }
private void initAdapter() { mAdapter = new RefreshAndLoadMoreAdapter(this, dataList); superRecyclerView.setAdapter(mAdapter); }