android使用DialogFragment出现java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState的解决方法

时间:2019-02-19 20:26:24   收藏:0   阅读:317
调用 dialog.show(getSupportFragmentManager(), "tag");时出现了java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState的错误。

报错的原因:dialog.show()方法的内部使用了commit()方法提交事务,某些时候因为状态异常而报错。解决方法就是使用commitAllowingStateLoss()方法,具体如下所示:

解决方法:getSupportFragmentManager().beginTransaction().add(dialog, "tag").commitAllowingStateLoss();

 

原文:https://www.cnblogs.com/yongfengnice/p/10403000.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!