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?

Brad Hein
  • 10,997
  • 12
  • 51
  • 74

1 Answers1

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

RoflcoptrException
  • 51,941
  • 35
  • 152
  • 200
  • I just mixed up ViewFlipper with ViewSwitcher, so my comment was moot. – alexanderblom May 25 '10 at 04:21
  • @RoflcoptrException 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 class – Mr.G May 08 '13 at 10:33