Dianne, Thanks. I do wonder though, would it have been possible, architecturally, to separate "showing" a fragment from "adding" a fragment to the fragment manager.
For example when I "show" a dialog fragment it does both "adding" and "showing" of that fragment. Sameway when I dismiss a dialog, it stops "showing" the fragment and also "removes" it. So I have no mechanism to retain that fragment once it is dismissed. So "state" is intimately tied to "visibility". But again I am just getting to know them and probably there are stronger reasons to tie them strongly to the UI Thanks again for your tireless support on this forum and elsewhere. Satya On Mon, Feb 21, 2011 at 2:30 PM, Dianne Hackborn <[email protected]> wrote: > You can only maintain a fragment pointer if it is actually added to the > fragment manager. > > On Mon, Feb 21, 2011 at 7:24 AM, Satya Komatineni > <[email protected]> wrote: >> >> The reason I am not able to do this is because >> >> 1. To hold on to this fragment pointer I need to save/restore the >> pointer through the save bundle >> 2. I am using putFragment() method to do this (via the activity >> onsaveinstancestate) >> 3. putFragment() seem to require that the fragment is added to the >> fragment manager >> 4. however when a fragment dialog is "dismiss"ed it is removed from >> the fragment manager. So I cannot do a put fragment. Not only that the >> fragment manager will not even recreate the fragment because it is >> removed by "dismiss". I want to keep it there even if it is dismissed >> so that the fragment manager can keep its state. >> >> I suppose I can always maintain the state of the dialog outside of it, >> but I am trying to see if there is a way to do this without resoring >> to separatng the state data. >> >> >> In more detail >> ***************** >> If the above post is a bit dense here is psuedo code I am trying to do >> >> >> MyActivity >> { >> private MyDialogSegment ds = null; >> >> private void initMyDialogSegment(Bundle savebundle) >> { >> if (fragmentmanager.getfragment("mytag")) has it >> ds = restoredfragment; >> else >> ds = MyDialogSegment.newInstance(....); >> fragmentmanager.add(null, ds, "mytag"); >> } >> >> public showDiloag() >> { >> ..... >> ds.show(ft, "mytag"); >> } >> public onDismissCallback() >> { >> ds.getSomeState(); >> } >> >> onSaveInstanceState(bundle b) >> { >> fragmentmanager.putfragment(ds,"mytag"); >> } >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en > > > > -- > Dianne Hackborn > Android framework engineer > [email protected] > > Note: please don't send private questions to me, as I don't have time to > provide private support, and so won't reply to such e-mails. All such > questions should be posted on public forums, where I and others can see and > answer them. > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- Satya Komatineni http://www.satyakomatineni.com http://www.androidbook.com -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

