Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android pull-to-refresh show loading footer at start

I am using the old version of Android PullToRefresh library. It works fine for triggering loading when over scrolling.

However, I want to show the loading footer view when I first enter my activity. I tried many times but still cannot find a correct way.

Is there anybody could help me out?

like image 314
Robin Avatar asked Nov 30 '22 19:11

Robin


2 Answers

Set PullToRefreshListView mode:

<com.handmark.pulltorefresh.library.PullToRefreshListView
ptr:ptrMode="pullFromEnd"
ptr:ptrAnimationStyle="rotate"
/>

call

getRefreshableListView().setRefreshing();

where getRefreshableListView() is your method that finds actual PullToRefreshListView. After initial loading of your data don't forget to call

getRefreshableListView().onRefreshComplete();

if setRefreshing() does not work, try using postDelayed():

getRefreshableListView().postDelayed(new Runnable() { getRefreshableListView().setRefreshing();}, 200);
like image 26
agamov Avatar answered Dec 10 '22 12:12

agamov


try to set it to show footer with a delay of 300-500 millis,sometimes it doesn't have enough time to initialise

new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            mPullRefreshGridView.setRefreshing(true);
        }
    }, 500);

this solved the problem to me

like image 174
Eddy Avatar answered Dec 10 '22 11:12

Eddy