質問

I'm using chrisbanes's Android-PullToRefresh in my app.

I need to disable pulltorefresh functionality for first time fragment launch - when list is empty and items are downloading in background. In this case (list is empty) user can swipe down and progressbar with "Release to refresh" will shown.

After loading all items I want to enable pulltorefresh functionality..

How?

役に立ちましたか?

解決

I had same problem.

According to source, if view is disabled, it'll not eat touch event.

https://github.com/chrisbanes/ActionBar-PullToRefresh/blob/master/library/src/uk/co/senab/actionbarpulltorefresh/library/PullToRefreshLayout.java#L137

simply, you can do

mPullToRefreshLayout.setEnabled(false);

他のヒント

By default you disable pull to refresh and enable in asyncTask of post execute when to fill adapter of list.

You could put a count and call the method to refresh only when this count is bigger than 0(zero) and set a listener on scroll event to set count to 0(zero), so everytime that the user scroll you list, the count will be set to 0(zero) and when the list arrive on the top and scroll up again you refresh method will be called.

mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
                @Override
                public void onRefresh() {
                    if (countDelay > 0) {
                        countDelay = 0;
                        refresh();
                    } else {
                        mSwipeRefreshLayout.setRefreshing(false);
                        countDelay++;
                    }
                }
            });
mSwipeRefreshLayout.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
                @Override
                public void onScrollChanged() {
                    countDelay = 0;
                }
            });

hope this help someone with the same issue:

mRefreshableListView.setMode(PullToRefreshBase.Mode.DISABLED);//to disable the pull functionality
mRefreshableListView.setMode(PullToRefreshBase.Mode.PULL_FROM_END);//or whatever you want
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top