android fragment addview,Android中Fragment怎么addView?

这篇博客详细介绍了在Android中如何使用Fragment,包括在布局文件中使用fragment标签和通过FragmentTransaction动态添加Fragment。通过一个实例展示了如何在ListFragment中实现点击列表项展示详情,同时提到了在SDK1.6及更低版本上使用Fragment需要借助android-support-v4.jar库。
摘要由CSDN通过智能技术生成

Fragment是Android honeycomb 3.0新增的概念,在Android——Fragment介绍、Android

Fragment使用、Android FragmentManage

FragmentTransaction介绍中做了关于Fragment的详细介绍。这一片主要通过一个实例了解Fragment的使用。

先看一下布局文件(layout):

android:orientation=“horizontal” android:layout_width=“match_parent”

android:layout_height=“match_parent”>

class=“com.fragment.main.TitlesFragment”

android:id=“@+id/titles” android:layout_weight=“1″

android:layout_width=“0px” android:layout_height=“match_parent” />

android:layout_width=“0px” android:layout_height=“match_parent”

android:background=“?android:attr/detailsElementBackground” />

布局文件中使用了fragment标签和FrameLayout标签。Android Fragment使用

中介绍了2中嵌入Fragment的方法,这个实例中都用到,从布局文件看到有了fragment标签,这是一种使用方法,FrameLayout标签将会成为第二种加载fragment的载体view。

看一下程序实现(com.fragment

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值