`
Darar
  • 浏览: 87843 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

The specified child already has a parent. You must call removeView() on the chil

 
阅读更多

在开发中这么一个场景。如果你是用onCreateDialog showDialog 系统的一系列方法去操作dialog 那么当你dialog存在时,你离开了当前的activity。再回到此activity时,点击dialog上的按钮,按钮的事件是显示另一个dialog。则你会发现以下异常:

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

 

原因

1. 在你离开界面再回来时,系统会掉Activity中的performRestoreInstanceState方法。此方法里把所有的dialog又重新初始化了一遍。则当你触发showDialog操作时, 就会出现以上异常,说你必须先removeView才能再addView.。所以当你的界面需要在离开页面 dialog不关的场景下, 最好不要用系统的dialog操作方法。

分享到:
评论

相关推荐

    关于IllegalStateException: The specified child already has a parent.

    IllegalStateException: The specified child already has a parent.我的博客中有文章讲解

    模拟微信界面2

    在使用ViewPager + Fragment 的时候报错:The specified child already has a parent. You must call removeView() on the child’s parent first.

    微信主界面

    在使用ViewPager + Fragment 的时候报错:The specified child already has a parent. You must call removeView() on the child’s parent first

    尚学堂android开发常用错误集.docx

    You must call removeView() on the child's parent first. ``` **原因分析**: 尝试将一个已经存在于父视图中的子视图添加到另一个父视图中。在进行添加操作前,需要先从当前的父视图中移除该视图。 **解决方案*...

    VMWare (specified virtual disk needs repair...)修复

    specified virtual disk needs repair。附修复工具和使用方法。 分数不够的可以到VM官方下载修复工具,如果找不到就贡献1分下载我上传的吧:) =====================================================================...

    MFC ModifyStyle

    (If WS_CLIPSIBLINGS is not given and child windows overlap, when you draw within the client area of a child window, it is possible to draw within the client area of a neighboring child window.) For ...

    cesiumlab依赖库.zip

    Error: The specified module could not be found. 1\?C:\Program Files\cesiumlab2\tools\LabNative.node 请下载此依赖底(包含vcruntime140_1.dll和msvcp140_1.dll),解压到C:\Windows\System32下

    hibernate-shards.jar

    or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must ...

    解决Mysql Error-The user specified as a definer (‘mysql.infoschema’

    在MySQL数据库操作中,"The user specified as a definer (‘mysql.infoschema’@’localhost’) does not exist" 是一个常见的错误提示,这通常发生在尝试执行存储过程、触发器或者视图等对象时,这些对象的定义者...

    WizFlow网页编辑

    or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must ...

    Java自定义异常案例--ExceptionManager(java源码)

    * Show the information in a dialog which has the specified title and belongs to the * specified component. * * @param parent The component cause the exception. * @param title The title of ...

    'FrontEnd Plus' The GUI for the fast JAva Decompiler.

    In a case you want to check the accuracy of the decompilation or just curious, there is an option -a which tells Jad to annotate the output with JAVA Virtual Machine bytecodes. Jad supports the inner...

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    on a curve by the distance from the original point on the perimeter. - ADD: Added the method TCustomProp.GetPublishedComplexProp - returns included complex flex-property by name registered through ...

    微软内部资料-SQL性能优化5

    On a qualified select, update, or delete, the correct leaf page will be the lowest page of the tree in which one or more rows with the specified key or keys reside. A qualified operation is one that ...

    Addison.Wesley.The.Java.Programming.Language.4th.Edition.Aug.2005.chm

    and the impact this has on some of the new language features. <br>Appendix BUseful Tableshas tables of information that you may find useful for quick reference. <br>Finally, Further Reading ...

    Universal-USB-Installer

    gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know ...

    The user specified as a definer ('root'@'%') does not exist 解决方法

    mysql 1449 : The user specified as a definer ('root'@'%') does not exist 解决方法

    Proxy Server(代理服务器)

    Once a child has been forked, the parent resumes listening for additional connections. The name of the isolated host and the port to serve as proxy for, as well as the port number the ...

    ASP.NET The system cannot find the file specified解决办法

    ASP.NET The system cannot find the file specified解决办法 Server Error in ‘/’ Application. The system cannot find the file specified Description: An unhandled exception occurred during the execution...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    On the other hand, you must include the header file for Foo if your class subclasses Foo or has a data member of type Foo. Sometimes it makes sense to have pointer (or better, scoped_ptr) members ...

Global site tag (gtag.js) - Google Analytics