The swipe to refresh user interface pattern is implemented entirely within the SwipeRefreshLayout widget, which detects the vertical swipe, displays a distinctive progress bar, and triggers callback methods in your app. You enable this behavior by adding the widget to your layout file as the parent of a ListView or GridView, and implementing the refresh behavior that gets invoked when the user swipes.
This lesson shows you how to add the widget to an existing layout. It also shows you how to add a refresh action to the action bar overflow area, so that users who may be unable to use the swipe gesture can trigger a manual update with an external device.
You should add a refresh action to your app’s action bar to ensure that users who may not be able to perform a swipe gesture can still trigger a manual update. For example, users with accessibility needs can trigger action bar actions using external devices, such as keyboards and D pads.
You should add the refresh action as a menu item, rather than as a button, by setting the attribute android show As Action never. If you display the action as a button, users may assume that the refresh button action is different from the swipe to refresh action. By making the refresh action less conspicuous in the action bar, you can encourage users to perform manual updates with the swipe gesture while still maintaining the accessible option in a place where D pad users would look for it.