viewStub
<ViewStub
android:id="@+id/fm_maps_guiji_vs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout="@layout/ly_datetime" >
</ViewStub>
ly_datetime viewstub中引用的文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="horizontal"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="10dp"
android:visibility="gone" >
代码中调用 View vs = vt.inflate();
ViewStub vt;
vt = (ViewStub) findViewById(R.id.fm_maps_guiji_vs);
View vs = vt.inflate();
layout3 = (LinearLayout) vs.findViewById(R.id.layout_3);
year = (WheelView) vs.findViewById(R.id.year);
month = (WheelView) vs.findViewById(R.id.month);
day = (WheelView) vs.findViewById(R.id.day);
include
与正常写在布局文件中一样使用
本文详细介绍了Android中ViewStub的使用方法及其应用场景。通过具体的代码示例展示了如何在布局文件中定义ViewStub,并在运行时通过inflate方法加载指定的布局文件。此外还探讨了ViewStub与include标签的区别。


被折叠的 条评论
为什么被折叠?



