天天看點

Android自定義下拉、加載更多控件

話不多說,先上效果圖

Android自定義下拉、加載更多控件

簡單粗暴的下拉重新整理是怎麼實作的呢,非常簡單,首先點此下載下傳自定義控件

emmmmm。。。。沒積分下載下傳的,來py(q 1107834296)

然後當做module項目導入,

Android自定義下拉、加載更多控件

把這個module項目依賴到目前主工程

Android自定義下拉、加載更多控件
Android自定義下拉、加載更多控件

非常簡單,然後接下來在項目布局中使用就好了

<com.handmark.pulltorefresh.library.PullToRefreshListView android:id="@+id/pulist_transaction_record_list" android:layout_width="match_parent" android:layout_height="match_parent" android:cacheColorHint="@color/transparent" android:divider="@null" android:scrollbars="none" android:drawSelectorOnTop="false" android:fadeScrollbars="true" android:fadingEdge="none" android:fadingEdgeLength="0dp" android:footerDividersEnabled="false" android:headerDividersEnabled="false" android:listSelector="@color/transparent" pulltorefresh:ptrAnimationStyle="flip" pulltorefresh:ptrDrawable="@drawable/xlistview_load_progressbg" pulltorefresh:ptrDrawableEnd="@drawable/pulltorefresh_head_indicate" pulltorefresh:ptrDrawableStart="@drawable/pulltorefresh_head_indicate" tools:ignore="PxUsage" />

代碼裡設定一個重新整理的監聽

pulist_transaction_record_list.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
    @Override
    public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
        //此處填寫重新整理的資料的方法
        onRefresh();
    }

    @Override
    public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
        //此處填寫重新整理的資料的方法
    }
});
           

到此下拉重新整理就可以用了,快去試試吧。