I know that when you're first instantiating a fragment you can pass arguments using setArguments(Bundle)
and retrieve them in the fragment using getArguments()
.
However, in my app I have fragments that will be detached and attached several times after they've been added to an activity. On re-attach, I may need to pass a fragment an argument to modify its content prior to reattaching it. I can use setArguments
the first time I display the fragment, but on subsequent occasions that won't work. The savedInstanceState
will not work in this case as I won't know the value of the argument prior to detaching the fragment.
I know I could just implement a method that I would call before attaching the fragment that would set an argument, but it just seems like this is something that might already be in the API and I'm just not seeing it.
Is there something built-in that will allow me to do this, or will I have to implement this on my own? For the record, I am using the support package (v4).
Many thanks!