Android uses pulltorefresh to realize the effect of pull-up loading and pull-down refresh
Before introducing the main text, let's introduce and show you the operation diagram. If you feel it's good, please continue to read:
Related reading: share the experience of using pulltorefresh in Android
Project synchronized to: https://github.com/nanchen2251/pullToRefreshDemo
Simple use details:
1) Studio can search directly in the module settings of the app, but - must be added instead of spaces. In order to better understand this thing, I recommend you to go here and provide the website: https://github.com/chrisbanes/Android-PullToRefresh
Therefore, after downloading from git, import the library through the import module function of studio, and modify the gradle file of the library to be consistent with your own project
2) Then add the dependency and associate the app with it.
3) Open the library below to see a lot of things. This can support not only listview, but also GridView and scollview. It can be said that it is quite comprehensive. However, the landlord has not tried whether it can be used with the current hot recyclerview.
4) Next, in our XML layout, I use the properties of the custom control, so I add an xmlns: app= http://schemas.android.com/apk/res-auto
5) Because we use its listview here, we need a java bean and an item layout to customize the layout.
And list_ item.xml
6) It's very easy to use. In activity, the code comments have been relatively comprehensive. Here we simulate the asynchronous data download task and rewrite adaper. As for why we use static internal classes, there are many benefits. You can baidu popular science.
The above is the code that Xiaobian introduced to you about Android using pulltorefresh to achieve pull-up loading and pull-down refresh effect. I hope it will be helpful to you. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!