java.lang.IllegalStateException: Fragment already active
来源:互联网 发布:风险矩阵法三个区 编辑:程序博客网 时间:2024/05/18 02:18
1. 问题描述:
在使用Fragment的setArguments(Bundle args)来传递参数到Fragment时,如果该Fragment是之前已经new出来的Fragment,
不是本次重新new出来的Fragment,这是再次调用setArguments(Bundle args) 则会发生该Exception。
2.解决方案:
Reading the setArguments(Bundle args) source will help you understand:
/*** Supply the construction arguments for this fragment. This can only* be called before the fragment has been attached to its activity; that* is, you should call it immediately after constructing the fragment. The* arguments supplied here will be retained across fragment destroy and* creation.*/public void setArguments(Bundle args) { if (mIndex >= 0) { throw new IllegalStateException("Fragment already active"); } mArguments = args;}
You cannot use setArguments(Bundle args) again in your code on the same Fragment. What you want to do I guess is either create a new Fragment of and set the arguments again. Or you can usegetArguments() and then use the put
methods of bundle to change it's values.
0 3
- java.lang.IllegalStateException: Fragment already active
- java.lang.IllegalStateException: Fragment already active
- 异常:java.lang.IllegalStateException: Fragment already active
- java.lang.IllegalStateException: Fragment already active
- 异常:java.lang.IllegalStateException: Fragment already active
- 使用Fragment时出现 java.lang.IllegalStateException: Fragment already active
- java.lang.IllegalStateException: Fragment already active,Fragment.setArguments()问题
- Android运行异常二:java.lang.IllegalStateException: Fragment already active
- 在fragment中向另一个fragment传递数据时java.lang.IllegalStateException: Fragment already active
- java.lang.IllegalStateException: Transaction already active
- java.lang.IllegalStateException: Fragment already added问题
- java.lang.IllegalStateException: Fragment already added:
- java.lang.IllegalStateException: Fragment already added:
- 解析 IllegalStateException--"Fragment already active"
- java.lang.IllegalStateException: Fragment already added异常的处理
- 关于java.lang.IllegalStateException: Fragment already added的一些问题
- java.lang.IllegalStateException: Fragment already added ListFragment异常的处理
- 关于java.lang.IllegalStateException: Fragment already added的问题
- 【问题】multiple definition of `_start'
- iOS本地通知:UILocalNotification
- 解决:LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏
- 80后创业故事之:兄弟散伙,创业失败
- iOS 真机
- java.lang.IllegalStateException: Fragment already active
- 窗口糊涂综合征
- 端口号是什么概念
- POJ-3728-The merchant
- 类之间的转换
- Spring学习4-面向切面(AOP)之aspectj注解方式
- linux 下 samba的安装
- MapReduce(一): Hadoop的简单配置运行
- js 弹出确认 取消对话框