PullToRefresh上下拉刷新使用步骤

PullToRefresh是一套实现非常好的下拉刷新库,它支持:

1.ListView

2.ExpandableListView

3.GridView

4.WebView

使用步骤:

一、

将PullToRefreshlibrary 导入到android studio中(import module),

更改pullToRefreshlibrary的build.gradle

compileSdkVersion 23
buildToolsVersion "24.0.1"(跟你项目的build.gradle一致)

二、修改过时的MathFloor方法

三、在你的app中引用

例如:

<com.handmark.pulltorefresh.library.PullToRefreshGridView
    android:layout_marginLeft="12dp"
    android:id="@+id/pullgv_tuijian_jingcai"
    android:layout_below="@id/lin_hot"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:horizontalSpacing="1dp"
    android:verticalSpacing="1dp"
    android:numColumns="3">
</com.handmark.pulltorefresh.library.PullToRefreshGridView>

2、在MainActivity.class中

private PullToRefreshGridView myPullToRefreshGridView;
//初始化控件
public void InitView() {
    myPullToRefreshGridView = (PullToRefreshGridView) view.findViewById(R.id.pullgv_tuijian_jingcai);
    myPullToRefreshGridView.setMode(PullToRefreshBase.Mode.BOTH);//设置模式能上下拉刷新
}

 

三、

重写setOnRefreshListener方法

myPullToRefreshGridView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<GridView>() {
    @Override
    public void onPullDownToRefresh(PullToRefreshBase<GridView> refreshView) {
        GridView_jingcai(ContanPath.PATH_JINGCAI +1);
    }

    @Override
    public void onPullUpToRefresh(PullToRefreshBase<GridView> refreshView) {
        GridView_jingcai(ContanPath.PATH_JINGCAI +(++i));
    }
});

 

4、实现分页加载,改变页面索引,并用

adapter.notifyDataSetChanged();

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值