ListView的 addHeaderView,addheaderview

來源:互聯網
上載者:User

ListView的 addHeaderView,addheaderview

  在代碼中使用 listView .addHeaderView(...) 方法可以在ListView組件上方添加上其他組件,並且連結在一起像是一個新組件。如果多次使用 .addHeaderView(...) ,則最先添加的組件在最上方,按添加的先後順序由上到下羅列。

此時listView 的 position = 0 的位置對應的是view1,而不再是原來listView中的第一條了。

 

若要對做原來的ListView做不可見設定,可使用將listView的adapter中資料置空的方法,在可見時再還原資料,如:

--隱藏 ListView --

 mStaffAdapter.mDataList=new ArrayList<Map<String,Object>>();
 mStaffAdapter.notifyDataSetChanged();

--展開 ListView --

 mStaffAdapter.mDataList=mStaffDataList;//mStaffDataList是原來的快取資料
 mStaffAdapter.notifyDataSetChanged();

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.