ChrisBanes PullToRefresh 'Loading…' issue

前端 未结 2 589
挽巷
挽巷 2021-01-13 12:49

I am using PullToRefresh ListView from chrisbanes which I found here.

I implemented it successfully, thanks to its documentations. :)

However, I am stuck at

2条回答
  •  广开言路
    2021-01-13 13:33

    After banging my head for almost 3hours I was able to solve this. It was quite simple tough.

    What I did was created a Handler and a Runnable which calls mPullRefreshListView.onRefreshComplete(); and checked after some time that if mPullRefreshListView was still refreshing then call the method again which closes it on the next call. :)

    Code goes like this..

    @Override
    public void onRefresh(PullToRefreshBase refreshView) {
     if (hasMoreData()) {
        // Call service when pulled to refresh
        toastShort("Last");
        orderService();
     } else {
        // Call onRefreshComplete when the list has been
        // refreshed.
        toastShort("No more data to load");
        upDatePull();  //this method does the trick
     }
    }
    
    
    private void upDatePull() {
     // lvOrders.setAdapter(null);
     handler = new Handler();
     handler.postDelayed(runnable, 1000);
    }
    
    Runnable runnable = new Runnable() {
    @Override
    public void run() {
        mPullRefreshListView.onRefreshComplete();
        if (mPullRefreshListView.isRefreshing()) {
            Logger.d("xxx", "trying to hide refresh");
            handler.postDelayed(this, 1000);
        }
    }
    };
    

    Credits to this link.

提交回复
热议问题