Android: Add custom headers and tails for the ListView, pull up active load. (citation)

Source: Internet
Author: User

1. Head and tail


(1) Set a self-justification XML layout my_headview.xml


Find this custom layout in the Activity class and add it to the head


LinearLayout hearderviewlayout = (linearlayout) layoutinflater. (
Xwactivity.this). Inflate (R.layout.my_headview, NULL);


Listview.addheaderview (hearderviewlayout);


(2) Set a self-justification XML layout my_footview.xml


LinearLayout footviewlayout = (linearlayout) layoutinflater. (
Xwactivity.this). Inflate (R.layout.my_footview, NULL);


Listview.addfooterview (footerviewlayout);


(3) Importance of business


The ListView is bound to have adapter, take part in the head tail, must before participating in adapter!


Listview.addheaderview (hearderviewlayout);


Listview.addfooterview (footerviewlayout);


Listview.setadapter (Myadapter);



1. Add the listening pieces to the rear


Listview.setonscrolllistener (New Onscrolllistener () {
public void onscrollstatechanged (Abslistview view, int scrollstate) {
Switch (scrollstate) {
Case Onscrolllistener.scroll_state_idle://When transitions are not migrated
Conclude that migration is shifting to the bottom
if (view.getlastvisibleposition () = = (View.getcount ()-1)) {

Add a manipulation here

}
Break
}
}

public void Onscroll (Abslistview view, int firstvisibleitem,
int visibleitemcount, int totalitemcount) {

}
});

Article citation: http://blog.csdn.net/wangwei_cq/article/details/9383759

Android: Add custom headers and tails for the ListView, pull up active load. (citation)

Related Article

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.