1

I'm reusing the ListView AND the LayoutInflater here for both a header and a footer:

ListView lv = getListView(); 
LayoutInflater inflater = getLayoutInflater(); 
View header = (View)inflater.inflate(R.layout.header, lv, false);
lv.addHeaderView(header, null, false);

View footer = (View)inflater.inflate(R.layout.footer, lv, false);
lv.addFooterView(footer, null, false);

I reckon reusing the ListView is perfectly sensible, but I'm not so sure about the LayoutInflater. Am I flirting with disaster here, or is this okay?

B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
  • 1
    to call getLayoutInflater(); once is fine :) the rest is also fine if you look at other samples they do it allover with inflater.inflate() – Sergey Benner Feb 13 '12 at 00:37

1 Answers1

1

Please refer to : http://developer.android.com/reference/android/widget/ListView.html#getFooterViewsCount()

Returns the number of footer views in the list. Footer views are special views at the bottom of the list that should not be recycled during a layout.

So yeah... I don't think you are doing anything wrong.

Saad Farooq
  • 13,172
  • 10
  • 68
  • 94