Android based on ListView to achieve a similar QQ space of scrolling page and rolling load effect _android

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.