//提供一個(布局)這個布局是一個xml,控件在xml中
View llHomeMember = inflater.inflate(R.layout.view_popuwindow_health_record_home_member, null);
//戶主關系
tv_home_member_view = (TextView) llHomeMember.findViewById(R.id.tv_home_member_view);
//姓名
tv_name_view = (TextView) llHomeMember.findViewById(R.id.tv_name_view);
//性別
tv_sex_view = (TextView) llHomeMember.findViewById(R.id.tv_sex_view);
//出生日期
tv_birthday_view = (TextView) llHomeMember.findViewById(R.id.tv_birthday_view);
//身份證號
tv_id_card_view = (TextView) llHomeMember.findViewById(R.id.tv_id_card_view);
//把數據set進控件,
//加載到容器中
ll_home_member.addView(llHomeMember);
這是布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:id="@+id/tv_home_member_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/square_frame"
android:text="戶主"
android:textSize="15sp"/>
<TextView
android:id="@+id/tv_name_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@drawable/square_frame"
android:layout_weight="1"
android:text="趙工"
android:textSize="15sp"/>
<TextView
android:id="@+id/tv_sex_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@drawable/square_frame"
android:layout_weight="0.5"
android:text="男"
android:textSize="15sp"/>
<TextView
android:id="@+id/tv_birthday_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@drawable/square_frame"
android:layout_weight="1"
android:text="1992-10-10"
android:textSize="15sp"/>
<TextView
android:id="@+id/tv_id_card_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@drawable/square_frame"
android:layout_weight="2"
android:text="500102199855547"
android:textSize="15sp"/>
</LinearLayout>
//這是容器
//1m2
<LinearLayout
android:orientation="vertical"
android:id="@+id/ll_home_member"
android:layout_width="match_parent"
android:layout_height="wrap_content">
//1m2
</LinearLayout>