开发者

How to dynamically do this in code rather than XML?

开发者 https://www.devze.com 2023-01-07 19:48 出处:网络
I would like to define the f开发者_开发技巧ollowing layout (which is currently an xml file) dynamically in my code.

I would like to define the f开发者_开发技巧ollowing 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>


You can use LayoutInflater and add elements dynamically to your custom view. Also see this post: view from layout

0

精彩评论

暂无评论...
验证码 换一张
取 消