android viewstub include的使用

来源:互联网 发布:文章千古事得失寸心知 编辑:程序博客网 时间:2024/05/20 08:01

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

与正常写在布局文件中一样使用


 

原创粉丝点击