Android program development listview pull-down refresh pull-up (sliding page) load more

In a recent project similar to microblog, there is an Android function to use listview's pull-down refresh to refresh the latest news, and pull-up refresh (sliding paging) to load more.

Sina Weibo is a typical example of this way.

When users read microblogs from the network, if they load all the unread microblogs at once, it will take a long time, resulting in a bad user experience. At the same time, the content of one screen is not enough to display so much content. At this time, we need to use another function, that is, the page of listview. In fact, this page can be made into a page on the client side or a page on the server side (when you click load, just load page n from the corresponding server!!!). Load data by paging, and users can load as much as they see.

Usually, this is also divided into two methods. One is to set a button, which can be loaded when the user clicks. The other is automatically loaded when the user slides to the bottom. Today, I will share with you the implementation of the function of automatically loading when sliding to the bottom.

The renderings are as follows:

The main processes of drop-down refresh are:

(1) . pull down to display the header view, which prompts the user to "pull down and refresh"

(2) Pull down to a certain extent, which exceeds the basic pull-down limit of refresh. We think that the refresh conditions are met, and prompt the user to "let go refresh". In effect, the user is allowed to continue to pull down

(3) If the user lets go, the user may pull down far more than the prompt header interface, so in this step, first bounce back to the prompt header interface, and then prompt the user "loading".

(4) . after loading, hide the prompt header interface.

So let's see how we can achieve it???

Step 1: since you want to display listview, you should have a listview container pulldown.xml

Step 2: customize an item object pulldown displayed in listview_ item.xml

Step 3: define a header's XML layout file pulldown_ header.xml

Step 4: if you need to pull up and update more, define a footer layout file at the bottom. Here, for convenience, only define a ProgressBar and textview. For more complex display, it's up to you ~ ~ ~ ~ ~ pulldown_ footer.xml:

Step 5: then the main file comes on stage::: Rewrite listview. The main task of this file is to provide the processing method of touch events.

Step 6: pull down refresh control. It is this control that really implements pull-down refresh, and the scrollonlistview above only provides touch events, etc

The seventh step: This java file is to encapsulate the data and then call the two files. No more nonsense, code:::

The whole program is completed. In short, the first two packages can be used. What's more, it's not too difficult to call.

The above is the listview drop-down refresh pull-up (sliding page) of Android program development introduced by Xiaobian. I hope it will help 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!

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