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)