I implemented SwipeRefreshLayout in my app. I need to change the height which has to be scrolled down to call onRefresh() method. Which method should I use to add a custom height ?
Implementation of SwipeRefreshLayout
private SwipeRefreshLayout swipeLayout;
In oncreate
swipeLayout = (SwipeRefreshLayout)view.findViewById(R.id.swipe_container); swipeLayout.setOnRefreshListener(this); swipeLayout.setColorScheme(android.R.color.holo_blue_dark, android.R.color.holo_green_dark, android.R.color.holo_purple, android.R.color.holo_orange_dark); swipeLayout.setSoundEffectsEnabled(true);
Implementing an AsyncTask in onrefresh method
@Override public void onRefresh() { // Asynctask to perform some task }
Android SwipeRefreshLayout is a ViewGroup that can hold only one scrollable child. It can be either a ScrollView, ListView or RecyclerView. The basic need for a SwipeRefreshLayout is to allow the users to refresh the screen manually.
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.
The reversion 21 of v4 support library has provided a API to set the distance.
public void setDistanceToTriggerSync (int distance)
Check the document here.
One more thing, the rev. 21 changed the behaviour of progress bar, it's now a circle image. Have no idea how to get the old way back.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With