In Android, recyclerview is used to realize pull-down refresh and pull-up loading

Recommended reading: adding headers and footers using recyclerview

Use of recyclerview HelloWorld

Recyclerview is a newly added SDK in Android l version to replace listview. Its flexibility and substitutability are better than listview. This article introduces how to add pull-down refresh and pull-up load to recyclerview. In the past, it was very convenient to add pull-down refresh and pull-up load to listview. Using addheaderview and addfooterview, the refresh of recyclerview also needs to be realized by adding head or foot to list. This article will not tell you in detail how to do a drop-down refresh and loading effect, but how to quickly use the existing well-known open source libraries to achieve the following effects for recyclerview.

Let's show you the effect picture first. Interested friends, please continue to read the full text.

This drop-down refresh is not realized by adding a headerview to the list, but a layer of ViewGroup is set outside the recyclerview. This ViewGroup supports drop-down refresh and can flexibly realize the drop-down refresh of some sub views. This is the famous Android ultra pull to refresh open source library, written by Liao Huqiu, but unfortunately it does not support pull-up loading, This article uses an open source library that expands on this library and realizes the pull-up effect. The pull-up effect is realized by adding footerview in recyclerview. GitHub address: https://github.com/Chanven/CommonPullToRefresh Thanks to the developers active in the open source community.

Specific implementation steps: (development tool: Android studio)

1: Gradle configuration build.gradle

2: Main layout file activity_ Nested outside a recyclerview in main.xml is a ViewGroup that supports drop-down refresh

3: List item layout RV_ Item.xml has a cardview card container outside and a textview inside

4: Adapter rvadapter.java of recyclerview

5: The most important activity implementation, mainactivity.java, has been annotated

The above content is a tutorial on using recyclerview to realize pull-down refresh and pull-up loading in Android. I hope it will be helpful to you!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>