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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:41:00+00:00 2026-05-23T20:41:00+00:00

In android, a fragment (say FragA ) gets added to the backstack and another

  • 0

In android, a fragment (say FragA) gets added to the backstack and another fragment (say FragB) comes to the top. Now on hitting back FragA comes to the top and the onCreateView() is called. Now I had FragA in a particular state before FragB got pushed on top of it.

My Question is how can I restore FragA to its previous state ? Is there a way to save state (like say in a Bundle) and if so then which method should I override ?

  • 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-23T20:41:00+00:00Added an answer on May 23, 2026 at 8:41 pm

    In fragment guide FragmentList example you can find:

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putInt("curChoice", mCurCheckPosition);
    }
    

    Which you can use later like this:

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        if (savedInstanceState != null) {
            // Restore last state for checked position.
            mCurCheckPosition = savedInstanceState.getInt("curChoice", 0);
        }
    }
    

    I’m a beginner in Fragments but it seems like solution of your problem 😉
    OnActivityCreated is invoked after fragment returns from back stack.

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

Sidebar

Related Questions

is it possible to insert one Android fragment into another? I haven't noticed any
Android comes with lots of system resources ( android.R ) that can be used
I want to override the onAttach() http://developer.android.com/reference/android/app/Fragment.html#onAttach(android.app.Activity ) method of a ListFragment from the
I'm trying to add a support.v4.app.Fragment to a PreferenceActivity header, like so: <header android:fragment=com.example.SupportFragmentSubClass
I'm building the example shown in this tutorial: http://thepseudocoder.wordpress.com/2011/10/04/android-tabs-the-fragment-way/ And I'm get some errors
I am working on a Fragment application in Android 2.2. It so happens that
I have a SeachView inside of a Fragment in an Android 3.1 application currently
Seems the Google-recommended way (using the android support library) for a fragment or activity
I'm developing a ListView in an Android Fragment. The class extends ListFragment. I tried
I am testing fragments in Android and I'm having some confusing behavior with Fragment

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.