This article describes the Android based on ListView to achieve a similar QQ space-like scrolling page and scrolling load effect. Share to everyone for your reference, specific as follows:
1. Rolling load
Listview.setonscrolllistener (new Onscrolllistener () {///Add scroll bar to bottom to load the remaining elements @Override public void onscrollstatechanged (Abslistview view, int scrollstate) {if (scrollstate = = Onscrolllistener.scroll_st
Ate_idle) {Loadremnantlistitem (); @Override public void Onscroll (Abslistview view, int firstvisibleitem, int visibleitemcount, int totalitemcount)
{}
}); Listview.setonitemselectedlistener (New Onitemselectedlistener () {//button to select item in list, the focus falls on the bottom view to load the remaining item @ Override public void onitemselected (adapterview<?> parent, view view, int position, long id) {if (Footerview =
= view) {Loadremnantlistitem ();
Listview.setselection (position-1);
@Override public void onnothingselected (adapterview<?> parent) {}}); private void Loadremnantlistitem () {//Roll to load remaining data//dynamic Change Listadapter.getcount () return value// Use handler to invoke listadapter.notifydatasetchanged (); Update data}
2. Scroll page
ListView Listener Code is the same
private void Loadremnantlistitem () {//Roll to load the remaining data
//Re listview.setadapter (newsadapter);
Use handler to call Listadapter.notifydatasetchanged (); Update Data
}
Note: At the bottom of the ListView you can try Listview.addfooterview (Footerview, NULL, TRUE) to display the words "load ..." to beautify the user experience, in Loadremnantlistitem () The display and display of dynamic control in "Loading ..." in the method
For more information on Android-related content readers can view the site: "Android graphics and image processing skills summary", "Android Development introduction and Advanced Course", "Android debugging techniques and common problems solution summary", " Android Multimedia How-to Summary (audio, video, audio, etc), summary of Android Basic components usage, Android View tips Summary, Android layout layout tips and a summary of Android controls usage
I hope this article will help you with the Android program.