Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View caching for Headers and footers in a list view

Tags:

java

android

It is possible to add header and footer views to a list views.Are these views cached? Like the get view mechanism ensures recycling view resources for the list and prevents excess memory consumption.Is a header/footer view also taken care similarly?

EDIT

Consider a layout(which is essentially a ) with such contents:

  • About 40 different fields divided into 5 viewgroups
  • a comments type layout which can have an arbit number of comments which need to expanded at will.

Ideally a scroll view would be a suitable candidate for this. But this makes the choreographer complain about skipping a 1000 odd frames.

Another possible solution could be a a list view with headers and footers. A list view somehow consumes lower memory wrt the aforementioned scroll view.

The caching and parcelling questions was me trying to understand if there can be a mechanism for view storing/retrieving which would make inflation and relocing of listeners an easier task instead of a one-for-all-purpose method like getView()

EDIT2 I do not want to use a scroll view since it would inflate all the views in the start.Making the activity/fragment consume a lot of memory

like image 326
Droidekas Avatar asked Jun 05 '15 15:06

Droidekas


1 Answers

It is possible to add header and footer views to a list views

yes ListView has the addFooterView and addHeaderView

Like the get view mechanism ensures recycling view reosurces for the list and prevents excess memory consumption. Is a header/footer view also taken care similarly?

No they are not.

In particular you can call both methods more than once. In this case you will have more footer/header views, and they will appear in the order of the insertion

like image 174
Blackbelt Avatar answered Nov 04 '22 21:11

Blackbelt