java.lang.IllegalStateException: Fragment already active
2014-09-02 10:17
330 查看
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:
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
of bundle to change it's values.
在使用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
putmethods
of bundle to change it's values.
相关文章推荐
- java.lang.IllegalStateException: Fragment already added:
- java.lang.IllegalStateException: Fragment already added问题
- java.lang.IllegalStateException: Fragment already added异常的处理
- java.lang.IllegalStateException: Fragment already added异常的处理
- java.lang.IllegalStateException: Fragment already added异常的处理
- android Fragment java.lang.IllegalStateException:The specified child already has a parent.
- java.lang.IllegalStateException: FragmentManager is already executing transactions
- 解决 java.lang.IllegalThreadStateException: Thread already started. 错误
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView
- 严重: Servlet.service() for servlet jsp threw exception java.lang.IllegalStateException: getOutputStream() has already been called
- java.lang.IllegalStateException: getWriter() has already been called for this response
- java.lang.IllegalStateException: getWriter() has already been called for this response问题解决
- java.lang.IllegalStateException: getOutputStream() has already been called for this response
- java.lang.IllegalStateException: getOutputStream() has already been called for this response
- java.lang.IllegalStateException: getOutputStream() has already been call
- java.lang.IllegalStateException: getWriter() has already been called for this response
- java.lang.IllegalStateException: Web app root system property already set to different value
- java.lang.IllegalStateException The specified child already has a parent. You must call removeView()
- java.lang.IllegalStateException: getOutputStream() has already been called for this response
- java.lang.IllegalStateException: getOutputStream() has already been called for this response