You must call removeView() on the child's parent first错误!
来源:互联网 发布:汤姆克兰西知乎 编辑:程序博客网 时间:2024/05/20 21:23
在切换Fragement的时候出现:错误信息
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
前面已经提到:
LayoutInflater的inflate() 三参方法的第三个参数指示在加载期间,展开的layout是否应当附着到ViewGroup (第二个参数)。传入true会在最后的layout中创建一个多余的view group。
Fragment简单入门
所以使用使用两个参数的时候会报上述错误。
需要最后一个参数为false.
public class FragmentA extends Fragment { /** * * @param inflater 加载fragment的xml布局文件的填充器。其inflate方法可将布局文件转化成View对象 * @param container 你的fragment layout将要插入的父ViewGroup(来自activity的layout)。 * @param savedInstanceState 是一个Bundle,如果fragment是被销毁后恢复的,它提供关于fragment的之前的实例的数据()。 * @return 返回一个View类型的对象 */ @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.fragment_a,container,false); //第一个参数,是要填充那个。第二个参数是要填充到哪里。可以直接写,传来的父ViewGroup //如果第三个参数不写false切换fragment的时候报错误。 /* You must call removeView() on the child's parent first*/ }}
0 0
- You must call removeView() on the child's parent first
- You must call removeView() on the child's parent first
- You must call removeView() on the child's parent first错误的解决方法
- You must call removeView() on the child's parent first错误!
- The specified child already has a parent. You must call removeView() on the child's parent first.错误
- Android PopupWindow You must call removeView() on the child's parent first.
- Android关于You must call removeView() on the child's parent first的解决
- Android 开发 Tip 4 -- You must call removeView() on the child's parent first
- The specified child already has a parent. You must call removeView() on the child's parent first.
- 二、The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent. You must call removeView() on the child's parent first
- The specified child already has a parent. You must call removeView() on the child's parent first
- The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent. You must call removeView() on the child's parent first
- The specified child already has a parent. You must call removeView() on the child's parent first.
- 总是报The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent. You must call removeView() on the child's parent first.解决办
- zoj 2301 || hdu 1199 Color the Ball 线段树 离散化
- 优先队列详解
- Mac OS X下的java环境的构建
- 跳转到本app的详细设置下
- 网易互联网2017,3月笔试题
- You must call removeView() on the child's parent first错误!
- 接上,进一步优化,LruCache缓存
- Js_检查复选框选中个数
- mysql中操作符<=>的意思
- 1
- 2
- C和C++的异常
- POJ 3349 Snowflake Snow Snowflakes (哈希表)
- 文章标题