How to dynamically do this in code rather than XML?
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
精彩评论