Best practice for viewflipper containing 10 linearlayouts?
Asked Answered
D

1

8

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?

Duality answered 23/5, 2010 at 22:59 Comment(0)
A
19

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

Advantageous answered 23/5, 2010 at 23:16 Comment(2)
I just mixed up ViewFlipper with ViewSwitcher, so my comment was moot.Checkerboard
@Advantageous i havealready integrated this. But i want to call the actions in different activity classes. coz i dnt want put the codes in to same activity classe (Button action) is it possible to bind (library_view) in to a separate classPeradventure

© 2022 - 2024 — McMap. All rights reserved.