To add Swipe Refresh we need to add android SwipeRefreshLayout widget under
activity_main.xml
fileInside
SwipeRefreshLayout
we need to put our refresh widget such as ListView,TextViewThen we need to add menu
Now we need to add some code to our
MainActivity.java
classFirst refer our SwipeRefreshLayout
SwipeRefreshLayout SRL;
inside
onCreate()
Method we need to add this simple code to hadle swiperefresh onClick listenerHere
myUpdateOperation()
is a method to handle our refresh thing and calls setRefreshing(false)
when it’s finished We need to add same code under
OnOptionsItemSelected
methodGithub Repository Link for example app
No comments:
Post a Comment