【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