android动态加载布局控件

//提供一个(布局)这个布局是一个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>

 

转载于:https://www.cnblogs.com/lucky-19920401/p/5855255.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值