您的位置:首页 > 其它

ListView的HeaderView和Footer

2016-04-17 23:44 211 查看

HeaderView介绍

HeaderView用法

属性中添加

ListView中属性listHeader和overScrollHeader区别:

android:overScrollHeader="@layout/header"
tools:listheader="@layout/header"

java代码中添加

listView通过以下方法添加

listView.addHeaderView(header1);
listView.addHeaderView(header2, null, false);

其中第二种方法的注释及方法声明如下:

/**
* Add a fixed view to appear at the top of the list. If this method is
* called more than once, the views will appear in the order they were
* added. Views added using this call can take focus if they want.
* <p>
* Note: When first introduced, this method could only be called before
* setting the adapter with {@link #setAdapter(ListAdapter)}. Starting with
* {@link android.os.Build.VERSION_CODES#KITKAT}, this method may be
* called at any time. If the ListView's adapter does not extend
* {@link HeaderViewListAdapter}, it will be wrapped with a supporting
* instance of {@link WrapperListAdapter}.
*
* @param v The view to add.
* @param data Data to associate with this view
* @param isSelectable whether the item is selectable
*/
public void addHeaderView(View v, Object data, boolean isSelectable)

headerView的添加有顺序性,即此处header1在header的上方

----------分割线------------

待更
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: