android - Fragment not added on orientation change -


I am using a piece like this:

  Public category MyFragment Expansion is expanded into MyListener {private string name, id; Public MyFragment () {} @ Override Creature on Public Zero (Bundle Saved Instant) {Super. If (Saved InstanceState! = Blank) {Log D. (Tag, "Restore the saved state"); // restore the ID; Name ....}} @ Override public view crate view (layoutInfleter inflator, view group container, bundle saved instenstate) {see V = inflator.In flat (R.Latite.Me_framement, container, falls); Return vi; } @ Override Public Empty on Activity Crateed (Bundle Saved Instantstate) {Super. On-activity creativity (saved instenstate); // work with asyncHttpClient, which will call "Onscreen Ready" after some time} @ Override Public Own On Response Readie () (if (! IsAdded ()) {Log D. (Tag, "piece not added"); Return; } Log D. (Tag, "piece added"); } @overworked public watch on sightstation (bundle outstate) {super. On Asvenstatestate (Outstate); OutState.putString (KEY_ID, this.id); OutState.putString (KEY_NAME, this.name); }}  

When I launch the app, I get a piece added message in the logcat, but if I rotate the device I could not find the piece , so if I try to use some visual (for example, a text view defined in my_fragment.xml ), then a IllegalStateException: fragment from MyFragment Activity Not connected .

Why does not attach piece to activity after an orientation change?


Comments