Posts

Showing posts with the label PullToRefresh Layout

Implementing Pull to Refresh Guide

Image
Overview In Android, the common "pull to refresh" UX concept is not built in to a ListView/RecyclerView. However, many Android applications would like to make use of this concept for their feeds. This is useful for all sorts of feeds such as a Twitter timeline. This effect can be achieved using the SwipeRefreshLayout from the support library , which was recently introduced and back-ported to all versions down to Android API level 4.   Using SwipeRefreshLayout SwipeRefreshLayout is a ViewGroup that can hold only one scrollable view as a child. This can be either a ScrollView or an AdapterView such as a ListView or a RecyclerView . Note: This layout only exists within more recent versions of support-v4 as explained in this post . Edit your app/build.gradle file to include a support library later than version 19: apply plugin : ' com.android.application ' // ... dependencies { // ... implementation ' com.android.support:support-v...

RecyclerRefreshLayout - Custom PullToRefresh Layout for Android

Image
RecyclerRefreshLayout based on the {@link android.support.v4.widget.SwipeRefreshLayout} The RecyclerRefreshLayout should be used whenever the user can refresh the contents of a view via a vertical swipe gesture. The activity that instantiates this view should add an OnRefreshListener to be notified whenever the swipe to refresh gesture is completed. The RecyclerRefreshLayout will notify the listener each and every time the gesture is completed again; the listener is responsible for correctly determining when to actually initiate a refresh of its content. If the listener determines there should not be a refresh, it must call setRefreshing(false) to cancel any visual indication of a refresh. If an activity wishes to show just the progress animation, it should call setRefreshing(true) . To disable the gesture and progress animation, call setEnabled(false) on the view . Note: The RecyclerRefreshLayout supports all of the views: ListView , GridView , ScrollView , FrameLayout , or ...