Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice for viewflipper containing 10 linearlayouts?

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?

like image 945
Brad Hein Avatar asked May 23 '10 22:05

Brad Hein


1 Answers

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

like image 62
RoflcoptrException Avatar answered Oct 18 '22 09:10

RoflcoptrException