views:

59

answers:

1

I would like to define the following layout (which is currently an xml file) dynamically in my code.

The end goal is to have the ability to conditionally include certain pages in my viewflipper.

Thanks!

<?xml version="1.0" encoding="utf-8"?>
<com.gtosoft.dash.MyViewFlipper
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/vFlipper" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content">

    <!--  Page 01 -->
        <include android:id="@+id/flipperPage01" layout="@layout/page01" />

    <!--  Page 02 -->
        <include android:id="@+id/flipperPage02" layout="@layout/page02" />

    <!--  Page 03 -->
        <include android:id="@+id/flipperPage03" layout="@layout/page03" />

</com.gtosoft.dash.MyViewFlipper>
A: 

You can use LayoutInflater and add elements dynamically to your custom view. Also see this post: http://stackoverflow.com/questions/3271440/view-from-layout/3271895#3271895

Mathias Lin