Android ListFragment自定义view报错解决方案

Android 3.0后引入了ListFragment,默认情况下Android已经给我们提供了一些简单的交互,但是那个进度条太丑了。

想自己定制下布局,在onCreateView里面inflat自定义layout的时候一直宝这个错‘The specified child already has a parent. You must call removeView() on the child's parent first.’ 各种尝试后发现inflat的第三个参数必须是false,

inflater.inflate(R.layout.list_layout, container, false);
记得以前不传第三个参数默认是false,今天总算又被坑了一回。

        第三个参数的意思是inflat出来的view是否附在rootview上面(这里的container)

attachToRoot Whether the inflated hierarchy should be attached to the root parameter? If false, root is only used to create the correct subclass of LayoutParams for the root view in the XML.


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值