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 7908543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:59:34+00:00 2026-06-03T11:59:34+00:00

I am having trouble understanding how Android deals with fragments (particularly nested fragments) on

  • 0

I am having trouble understanding how Android deals with fragments (particularly nested fragments) on an orientation change.

Say I have an activity a1 that loads a fragment f1. f1 then loads multiple instances of fragment f2 into itself in the oncreateview() method.

Now my activity a1 has this in (oncreate()):

if (savedInstanceState != null)
    return;

to make sure that multiple instance of f1 don’t get loaded. I do the same sort of thing in f1 to makes sure duplicate f2 instances don’t get loaded.

However, my class f1 needs to reference the f2 instances later on. Currently I am storing them in an ArrayList in the f1 object, however after an orientation change this ArrayList is empty and I think the f2 instances will be different objects any way.

So my question is, how is the best way to have nested fragments and to keep a reference to them after an orientation change?

  • 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-06-03T11:59:35+00:00Added an answer on June 3, 2026 at 11:59 am

    You can use FragmentManger to find references to other fragments.

    You can an get a reference to another fragment by doing something like:

    DetailsFragment details = (DetailsFragment) getFragmentManager().findFragmentById(R.id.details);
    

    or

    DetailsFragment details = (DetailsFragment) getFragmentManager().findFragmentByTag("my tag");
    

    If you have not already seen it take a look at this blog post.

    In your case where you have multiple instances of the same fragment you can set a tag when you create the fragment and use that instead of the id when looking for the fragment.

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

Sidebar

Related Questions

from here Im having trouble understanding they say that ado.net does not include a
I am having trouble understanding how layering is performed within Xcode. I have a
I am having trouble understanding how escaping works inside html tag attribute values that
I am having trouble understanding the difference between these two commands that in my
I'm having trouble understanding the following bit of code that I was hoping would
I'm having trouble understanding why Python raises a TypeError when you provide arguments that
I'm having some trouble understanding the search dialog in the Android SDK. The main
I am having a lot of trouble understanding how the Android context menu works.
I'm having trouble understanding how JQueryUI's autocomplete function deals with repeated keypresses resulting in
Im having trouble understanding class relationships after being asked to research it further, would

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.