The specified child already has a parent. You must call removeView
来源:互联网 发布:淘宝开店前期准备 编辑:程序博客网 时间:2024/05/22 04:54
今天学习使用fragment组件的时候,发现按照例子写完的程序一直报这个错误。对照代码以后发现犯了低级错误,一段代码的返回对象弄错了!!!
折腾了好久,真的是郁闷死了,来看错误的代码:
@Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {View rootView = inflater.inflate(R.layout.menulist, container, false);listView = (ListView) rootView.findViewById(R.id.menulist); listView.setOnItemClickListener(new OnItemClickListener() {@Overridepublic void onItemClick(AdapterView<?> parent, View view, int position, long id) {mCallback.onItemSelected(position, null);}});return listView;}
看到我返回的对象了吗? onCreateView 这个方法是要返回 layout 布局VIew对象才正确的,但是我返回成了 listView 组件对象,所以报错。
希望大家以后抄写代码的时候一定要细心,否则真的是要命啊!
另外网上一大堆说你的这个方法里 parent 没有执行removeView()方法的。我感觉这个错误的出现概率比较低,报这个错,不一定是这个问题,还是看看别的原因吧。
0 0
- The specified child already has a parent. You must call removeView() on the chil
- The specified child already has a parent. You must call removeView() on the
- java.lang.IllegalStateException The specified child already has a parent. You must call removeView()
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView
- java.lang.IllegalStateException The specified child already has a parent. You must call removeView()
- 异常-The specified child already has a parent. You must call removeView
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView(
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView(
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView(
- 关于异常“The specified child already has a parent. You must call removeView"的解决
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView(
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView(
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView(
- ava.lang.IllegalStateException: The specified child already has a parent. You must call removeView()
- ava.lang.IllegalStateException The specified child already has a parent. You must call removeView()
- The specified child already has a parent,you must call removeView()...
- The specified child already has a parent. You must call removeView
- 基于zookeeper实现分布式锁
- 几何总论
- 增加 ModelAndView 配置
- C++11的占位符std::placeholders
- JAVA初学者必备的连库类
- The specified child already has a parent. You must call removeView
- winform 关于双曲线的动态绘制
- 8 种 NoSQL 数据库系统对比
- HDOJ-----1069Monkey and Banana
- 如何在Win7安装MongoDB服务
- 个人知识管理最常见的误区有哪些?
- Libcurl 从FTP服务器下载
- Qt之自定义控件(开关按钮)
- JSP Session