Methods of adding headers and footers using recyclerview

The principle of recyclerview and listview is similar: both maintain only a small number of views and can display a large number of data sets. Recyclerview simplifies data display and processing in the following two ways:

Use layoutmanager to determine the arrangement of each item.

Provides default animation effects for adding and deleting items.

Although recyclerview has better performance improvement as a substitute for listview, some common functions of listview are not provided, such as addheaderview and addfooterview, which we often use. Since recyclerview does not provide this method, how should we add headers and bottoms to the list? By looking at the source code of listview, we can know that the header and footer of listview are dynamically added in the adapter, so we also add headerview and footerview to recyclerview according to this idea. Let's see the effect first

If you don't know how to use recyclerview, you can take a look at the previous blog posts

Use of recyclerview HelloWorld

Recyclerview uses many items to load the layout

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