Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SwipeRefreshLayout - swipe down to refresh but not move the view pull down

Is it possible ?? as a Title said

swipe down to refresh Layout but stick the Layout not move it down along swipe gusture

Thank you - I'm using SwipeRefreshLayout

like image 803
Jongz Puangput Avatar asked Apr 28 '14 12:04

Jongz Puangput


People also ask

How do I stop swipe refresh layout?

To disable the gesture and progress animation, call setEnabled(false) on the view. This layout should be made the parent of the view that will be refreshed as a result of the gesture and can only support one direct child.

How do I use swipe refresh layout?

To add the swipe to refresh widget to an existing app, add SwipeRefreshLayout as the parent of a single ListView or GridView . Remember that SwipeRefreshLayout only supports a single ListView or GridView child. You can also use the SwipeRefreshLayout widget with a ListFragment .

What is swipe refresh?

Swipe to refresh manually refreshes screen content with a user action or gesture.


1 Answers

I was also facing same issue. try this:

guidesList.setOnScrollListener(new AbsListView.OnScrollListener() {  
    @Override
    public void onScrollStateChanged(AbsListView view, int scrollState) {
    }

    @Override
    public void onScroll(AbsListView view, int firstVisibleItem, int   visibleItemCount, int totalItemCount) {

        int topRowVerticalPosition = (guidesList == null || 
            guidesList.getChildCount() == 0) ? 0 : guidesList.getChildAt(0).getTop();

        swipeContainer.setEnabled(firstVisibleItem == 0 && topRowVerticalPosition >= 0);
    }
});
like image 145
Noman Avatar answered Nov 15 '22 19:11

Noman