Swipe to refresh Android Activity (SwipeRefreshLayout)
In this tutorial, we will create swipe-to-refresh functionality in the Android. For this purpose, SwipeRefreshLayout widget should be used.
The instance of SwipeRefreshLayout adds an OnRefreshListener method and implements the code logic that will load on refresh. The vertical swipe displays a distinctive progress bar when the user swipes. The progress bar call setRefreshing(true) when it shows the progress animation or calls setRefreshing(false) to cancel.
Swipe to refresh Android Activity Example
In the activity_main.xml file, implement SwipeRefreshLayout widget.
Create an activity MainActivity.java and add the following code. In this class, we are checking the network connectivity onRefresh() the swipe.
Add the uses-permission in AndroidMenifest.xml file. The below-given permission is used to access network connectivity.
JavaTpoint offers too many high quality services. Mail us on [email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected]
Duration: 1 week to 2 week