像ListView一樣給GridView添加Header和Footer:HeaderFooterGridView

jopen 9年前發布 | 17K 次閱讀 Android開發 移動開發 HeaderFooterGridView

像ListView一樣給GridView添加Header和Footer,目前只添加了Header,后續完善中....

效果圖

image

Installation

compile 'com.hhl.headerfootergridview:headerfootergridview:0.1'

Usage

<com.hhl.headerfootergridview.HeaderGridView
        android:id="@+id/grid_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:numColumns="2"
        android:stretchMode="columnWidth"
        tools:listitem="@layout/header_view" />


 mGridView = (HeaderGridView) findViewById(R.id.grid_view);
        View headerView1 = View.inflate(this, R.layout.header_view, null);
        View headerView2 = View.inflate(this, R.layout.header_view, null);
        mGridView.addHeaderView(headerView1);
        mGridView.addHeaderView(headerView2);

        //setAdapter之前調用addHeaderView
        mGridView.setAdapter(mAdapter);

項目主頁:http://www.baiduhome.net/lib/view/home/1449998581920

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!