【Android异常】The specified child already has a parent. You must call removeView() on the child's parent first.


 

 

错误信息: 

Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

 

信息补充:

使用FragmentActvitiy + Fragment

 

错误原因:

    @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.preference_fragment, container);

 

解决办法: 

View v = inflater.inflate(R.layout.preference_fragment, container, false);

 

补充信息:

导致此错误并不一定就是这个原因,大家也能搜到很多其他的原因,这里备注一下。 

之前使用ActionBar里面的Fragment好像是可以的。 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM