Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7619905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:48:27+00:00 2026-05-31T03:48:27+00:00

I know that when you’re first instantiating a fragment you can pass arguments using

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:48:28+00:00Added an answer on May 31, 2026 at 3:48 am

    You can just expose a method on your fragment that set whatever you want to pass to it. To call it you can e.g. retrieve the fragment from the backstack by tag or keep an instance reference around from wherever you are calling it from.

    This works nicely for me although you need to be defensive in terms of null checks and such as well as aware of the lifecyle your fragment goes through when you attach it or restart it.

    From what I can tell there is nothing in the API…

    Update: This is still true and works just fine. I found that once this is more complex it is much cleaner and easier to use something like the Otto eventbus. Highly recommended imho.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that I can do something like $int = (int)99; //(int) has a
I know that you can insert multiple rows at once, is there a way
I know that the MsNLB can be configured to user mulitcast with IGMP. However,
I know that just using rand() is predictable, if you know what you're doing,
I know that we shouldn't being using the registry to store Application Data anymore,
I know that ads colors can be set up in account settings, but I
I know that, as of Java 1.5 , one can add a component to
I know that I can use virtual keyword to tell the entity framework that
I know that Cross validation is used for selecting good parameters. After finding them,
I know that you can set the number of threads to use for all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.