1.加头尾部
(1)定自义一个xml布局 my_headview.xml
在Activity类里找到这个自定义布局,并添加到头部
LinearLayout hearderViewLayout = (LinearLayout)
LayoutInflater.(
xwActivity.this).inflate(R.layout.my_headview, null);
listview.addHeaderView(hearderViewLayout);
(2)定自义一个xml布局 my_footview.xml
LinearLayout footViewLayout = (LinearLayout)
LayoutInflater.(
xwActivity.this).inflate(R.layout.my_footview, null);
listview.addFooterView(footerViewLayout);
(3)重视事务
listview必然会有Adapter,参加头尾部,必须在参加Adapter之前!
listview.addHeaderView(hearderViewLayout);
listview.addFooterView(footerViewLayout);
listview.setAdapter(myAdapter);
1.加上拉到尾部的监听件件
listview.setOnScrollListener(new OnScrollListener() {
public
void onScrollStateChanged(AbsListView view, int scrollState)
{
switch (scrollState) {
case
OnScrollListener.SCROLL_STATE_IDLE: // 当不迁移转变时
//
断定迁移转变到底部
if (view.getLastVisiblePosition() ==
(view.getCount() - 1)) {
//在这里添加操纵
}
break;
}
}
public void
onScroll(AbsListView view, int firstVisibleItem,
int
visibleItemCount, int totalItemCount) {
}
});
文章引自:http://blog.csdn.net/wangwei_cq/article/details/9383759