views:

376

answers:

2

I'm embarking on a GUI Activity composed of a viewflipper, which I would like to contain 10 linearlayout layouts.

Is it advisable to put all of my layouts into the same XML resource/layout file?

If not, is there a more organized approach to coding a viewflipper with many layouts?

Will having everything in the same file come at a significant performance cost?

+4  A: 

Personally, i would use the include tag for each separate view. So you can define a main xml where all the include tags are defined. in the following an example:

<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/flipper"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <include android:id="@+id/libraryView"  layout="@layout/library_view" />
    <include android:id="@+id/bookView"  layout="@layout/book_view" />
    <include android:id="@+id/workspaceView" layout="@layout/workspace_view" />
</ViewFlipper>

i defined a ViewFlipper and added some layout resources with the include tag. In this example you would have to define

library_view.xml
book_view.xml
workspace_view.xml

Hope this could help

Roflcoptr
Worked well - Thank you.
Brad Hein
Was going to say something, nevermind.
alexanderblom
@alex suspense... please share :) maybe you can earn a vote+
Brad Hein
I just mixed up ViewFlipper with ViewSwitcher, so my comment was moot.
alexanderblom
A: 

Is there any limit to how many children a view flipper may have ?

Simon Polak
Not sure, but keep in mind that the viewFlipper seems to inflate all the views at the same time, so adding a ton of views to the flipper may result in a noticeable delay when the activity starts up.
Brad Hein