Android recyclerview adds more functions of pull-up loading

The previous article introduced how to add footview to recyclerview. On this basis, it is actually very simple to add the function of paging loading. Last article address: add footview and headview for recyclerview

Effect: (the source code is at the end of the article)

Implementation key

On the basis of the previous code, you only need to add some modifications to the onbindviewholder (viewholder, int position) function, as follows:

In the function, first let the item display "loading...", Then, use the handler to refresh after a delay of two seconds. There are two main logical contents: one is to increase the maximum display capacity by 5, and the other is to refresh the content of the adapter.

Expansion and extension

In order to make it easy for readers to understand, the use of many places is rough, and it will not be so simple when readers really use it. Here are a few points for readers to learn: 1. Footview is generally not just a textview, and readers who have a certain pursuit of UI need to add at least one ProgressBar. 2. Generally, the content of the adapter is not directly passed in through the list and needs to be obtained from the network. Therefore, refreshing the content of the adapter generally requires a thread, rather than a simple handler here.

Source address: http://xiazai.jb51.net/201610/yuanma/PullRecyclerView (jb51.net). rar

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

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
分享
二维码
< <上一篇
下一篇>>