仿美团上拉加载下拉刷新详解BGARefreshLayout

1、下拉刷新上拉加载的选择

  这类框架也在网上找了好多,其实大多都是大同小异,只不过每个框架的样式不一样而已。看别人有用Xrecycleview的,但是感觉BGARefreshLayout样式要多一点就选择了它。

2、添加jar包

//下拉刷新框架
compile 'cn.bingoogolapple:bga-refreshlayout:1.1.8@aar'

3、添加xml页面


    
        
        
        
    

4、添加实现类

public class MainBuildingActivity extends MainActivity implements AMapLocationListener,View.OnClickListener,BGARefreshLayout.BGARefreshLayoutDelegate

5、具体代码:

private void initRefreshLayout() {
    mRefreshLayout.setDelegate(this);
    //true代表开启上拉加载更多
    BGAMeiTuanRefreshViewHolder meiTuanRefreshViewHolder = new BGAMeiTuanRefreshViewHolder(this, true);
    meiTuanRefreshViewHolder.setPullDownImageResource(R.drawable.location_refresh);
    meiTuanRefreshViewHolder.setChangeToReleaseRefreshAnimResId(R.drawable.location_refresh);
    meiTuanRefreshViewHolder.setRefreshingAnimResId(R.drawable.location_refresh);
    mRefreshLayout.setRefreshViewHolder(meiTuanRefreshViewHolder);
}

/**
 * 下拉刷新监听
 * @param refreshLayout
 */
@Override
public void onBGARefreshLayoutBeginRefreshing(BGARefreshLayout refreshLayout) {
    /*adapter.notifyDataSetChanged();
    mRefreshLayout.endRefreshing();*/
    Toast.makeText(MainBuildingActivity.this, "下拉刷新完成", Toast.LENGTH_SHORT).show();
}

/**
 * 上拉加载监听
 *
 * @param refreshLayout
 */
@Override
public boolean onBGARefreshLayoutBeginLoadingMore(BGARefreshLayout refreshLayout) {
    if(listBuilding.size()

6、程序下载地址:

https://download.csdn.net/download/f552126367/10313210

你可能感兴趣的:(Android)