Listview is used in Android applications to display the refreshed content in pages
Click the button to refresh 1. The effect is as follows:
Examples are as follows: the add data button in the figure above can be replaced with a progress bar. Because there is no data, I added a button to add to the database for testing; Generally, it takes some time to pull data from the server, so you can get a progress bar to prompt the user: when you click the load button, read the data from the database once and add the read data to the original data set; Then it displays
Pull down refresh when there is too much data to be displayed in the listview, in order to respond to users faster, it is more appropriate for the listview to display in pages at this time. The principle of listview paging data display is actually very simple. When the user slides to the last item of listview, it notifies the asynchronous thread to load the data of the next page. When the data of the next page is loaded, it calls the notifydatasetchange() method of the set adapter to display the data of the next page. Now there are two problems to be solved. The first problem is to know whether the user has slipped to the last item of listview; The second problem is how to prompt the user that the data of the next page is being loaded and make the user wait patiently. To solve the first problem, we just need to customize the listview and let it implement the onscrolllistener class to listen to the sliding state of the listview, so as to judge whether it slides to the last item. Here are just the main points:
To solve the second problem, it is also implemented in the onscroll () method