1

I have a layout comprising of many nested layouts some thing like shown below. But for one of the LinearLayout, (contentPanel in my case) i need to inflate around 10 views of different layout (some thing like list item) onto this contentPanel. how will i do that?

my layout structure:

<ScrollView>
  <LinearLayout>
  <RelativeLayout>
  <LinearLayout> ///contentPanel
  <LinearLayout>
<ScrollView>
suresh cheemalamudi
  • 6,190
  • 11
  • 49
  • 67
  • 1
    Hav u try viewstub Try this http://stackoverflow.com/questions/3893669/how-many-viewstubs-is-too-many-for-a-single-layout-xml-file/3893821#3893821 – Nitin Gupta Apr 17 '13 at 10:34

1 Answers1

3

You could certainly use a view stub as the comment suggests as these are reasonably inexpensive view elements.

However, you may still find you're not doing it the most efficient way if those 10 views of the different layout are quite expensive themselves.

I'm guessing you're considering manually inflating as you really wanted the benefits of a listview for these 10 elements- all those good things like view recycling, and the opportunity to use efficient patterns like ViewHolder BUT you rightly don't want to use a listview in a scrollview because that's a bad idea

Well, you might still be able to use a listview. Don't use the outer scroll view. Split the layouts into two groups- those below and above the contentPanel. Create a list view for the 10 different views and then the two groups to to that list view as a headerView and afooterView

Perhaps this will help.

Community
  • 1
  • 1
Tom
  • 1,773
  • 15
  • 23