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 ExampleIn the activity_main.xml file, implement SwipeRefreshLayout widget. activity_main.xmlCreate an activity MainActivity.java and add the following code. In this class, we are checking the network connectivity onRefresh() the swipe. MainActivity.javaRequired PermissionAdd the uses-permission in AndroidMenifest.xml file. The below-given permission is used to access network connectivity. |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India