android listviews: header and footer views android listviews: header and footer views android android

android listviews: header and footer views


Why not just collapse the header and footer to zero height, or gray out the buttons (even better).

And the best user experience, in my opinion, would be to dynamically load more items when needed (i.e. upon scroll), like the built-in Gmail app does.


Yes, this is a bug or oversight in the ListView component. You can work around this by writing your own WrapperListAdapter that handles adding and removing fixed list items, but I can tell you it's not entirely straightforward to do.

Alternatively — and much easier — you could add a fixed component above or below the ListView where you place the next and previous buttons.


How about reset the adapter at every time you need to add header view, like this way:

ListView.FixedViewInfo headerInfo = getListView().new FixedViewInfo();headerInfo.isSelectable=false ;headerInfo.view = feedInfoView;headerInfos.add(headerInfo);headerViewListAdapter = new HeaderViewListAdapter(headerInfos,null,adapter);getListView().setAdapter(headerViewListAdapter);