解决Fragment中:Can not perform this action after onSaveInstanceState
来源:互联网 发布:淘宝考试不 编辑:程序博客网 时间:2024/06/15 05:22
在使用FragmentTransition的 commit方法添加一个Fragment的时候出现的,后来在官网找到了相关的
说明:http://developer.android.com/reference/android/app/FragmentTransaction.html#commitAllowingStateLoss()
public abstract int commitAllowingStateLoss () Added in API level 11
Like commit()
but allows the commit to be executed after an activity's state is saved. This is dangerous
because the commit can be lost if the activity needs to later be restored from its state, so this should
only be used for cases where it is okay for the UI state to change unexpectedly on the user.
大致意思是说我使用的 commit方法是在Activity的onSaveInstanceState()之后调用的,这样会出错,因为onSaveInstanceState
方法是在该Activity即将被销毁前调用,来保存Activity数据的,如果在保存玩状态后再给它添加Fragment就会出错。解决办法就
是把commit()方法替换成 commitAllowingStateLoss()就行了,其效果是一样的。
阅读全文
0 0
- 解决Fragment中:Can not perform this action after onSaveInstanceState
- 解决Fragment IllegalStateException: Can not perform this action after onSaveInstanceState
- 解决fragment错误 Can not perform this action after onSaveInstanceState
- Fragment中出现Can not perform this action after onSaveInstanceState
- Fragment IllegalStateException: Can not perform this action after onSaveInstanceState
- Fragment 出现Can not perform this action after onSaveInstanceState
- fragment 异常IllegalStateException: Can not perform this action after onSaveInstanceState
- Can not perform this action after onSaveInstanceState(fragment异常)
- Fragment错误:IllegalStateException: Can not perform this action after onSaveInstanceState
- Fragment Or DialogFragment Can not perform this action after onSaveInstanceState
- Fragment Can not perform this action after onSaveInstanceState
- Fragment Or DialogFragment Can not perform this action after onSaveInstanceState
- fragment/dialogfragment异常:Can not perform this action after onSaveInstanceState
- fragment使用时 Can not perform this action after onSaveInstanceState
- Fragment坑之Can not perform this action after onSaveInstanceState
- Fragment系列之Can not perform this action after onSaveInstanceState
- Fragment异常:Can not perform this action after onSaveInstanceState
- Fragment Can not perform this action after onSaveInstanceState
- IDEA的Maven项目整合Spring和Mybatis框架出现ibatis.binding.BindingException: Invalid bound statement (not found)
- HDU 4704 Sum
- 用C++写的项目五子棋(单机,不涉及网络版本)
- Kotlin入门篇(五),Loop和Range,Kotlin中区间的定义和遍历
- linux查看进程线程数量命令:
- 解决Fragment中:Can not perform this action after onSaveInstanceState
- python3-PIL基本概念
- 自定义view group 1
- C# 调用mysql存储过程
- spak源码分析之sparkContext源码分析
- Java8新特性——内建的功能性接口
- 萌新的linux之旅24
- Can Place Flowers
- 为自己的人生负责