Android ListFragment自定义view报错解决方案
16lz
2021-01-23
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. |
---|
更多相关文章
- android五种布局模式
- Android的布局管理器与java中的实现方式不同
- 布局管理器
- 如何实现Android 布局背景模糊化处理
- android am 启动activity service or broadcast及参数传递
- Android五大布局对象