解决异常:IllegalStateException: Fragment <ThisFragment> is not currently in the FragmentManager
2015-03-21 14:47
519 查看
上午敲代码时出现这个问题,简单记录一下解决办法,有时间详细描述一下深层原因。
问题出现在这:
网上查看了一下,只需修改为如下:
意思是:在
问题出现在这:
[code]@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); getSupportFragmentManager().putFragment(outState, "mContent", mContent); }
网上查看了一下,只需修改为如下:
[code]@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (mFragment.isAdded()){ getSupportFragmentManager().putFragment(outState, "mFragment", mFragment); } }
意思是:在
onSaveInstanceState(Bundle outState)方法中保存fragment时,要先确保fragment是否已经加入到fragment manager中。
相关文章推荐
- <转> 解决异常:IllegalStateException: Fragment <ThisFragment> is not currently in the FragmentManager
- IllegalStateException: <Fragment> is not currently in the FragmentManager
- the type List is not generic; it cannot be parameterized with arguments<T>解决办法
- The method add(Fragment) in the type ArrayList<Fragment> is not applicable for the arguments (ImageF
- Zox's code life 人生就是不停的战斗! xxx is not in the sudoers file.This incident will be reported.的解决方法
- The MagicAjax HttpModule is not included in web.config. Add [<httpModules><add name="MagicAjax" type
- The method setClass(Context, Class<?>) in the type Intent is not applicable for the arguments (GameV
- xxx is not in the sudoers file.This incident will be reported.的解决方法
- 如何解决xxx is not in the sudoers file.This incident will be reported. on Mac
- VS:error C3872: '0xe044': this character is not allowed in an identifier解决方法
- The method load(Class, Serializable) in the type Session is not applicable for the arguments (Class<
- xxx is not in the sudoers file.This incident will be reported.的解决方法
- 错误:The MagicAjax HttpModule is not included in web.config. Add [<httpModules><add name="MagicAjax" type="MagicAjax.Magic
- xxx is not in the sudoers file. This incident will be reported (解决办法)
- Fedora提示 xxxis not in the sudoers file.this incident will be reported解决办法 [转]
- this class is not key value coding-compliant for the key buttonPressed.' 错误解决方式
- xxx is not in the sudoers file. This incident will be reported的解决方法
- map is not in the sudoers file.This incident will be reported.的解决方法
- 解决“could not find gem 'turn <>=0 ' in any of the gem sources listed in your gemfile”错误
- xxx is not in the sudoers file.This incident will be reported.的解决方法