I add one button programatically to my layout and would have expected 
Android to keep the layout, especially since the documentation of the 
onSaveInstanceState()-method says:

The default implementation takes care of most of the UI per-instance state 
for you by calling onSaveInstanceState() on each view in the hierarchy that 
has an id, and by saving the id of the currently focused view (all of which 
is restored by the default implementation of 
onRestoreInstanceState(Bundle)).

And in the source code of one of the examples I find this comment:

The system takes care of saving a view's state as long as an id has been 
assigned to the view.

My layout changes heavily in the event listeners and it would be very 
time-consuming and tiring to save the state and restore it again.

Am Freitag, 29. Juni 2012 17:57:48 UTC+2 schrieb MagouyaWare:
>
> What do I need to do to still have Button 2 on the screen after I
>> change the screen orientation?
>>
>
> You need to read up on the activity lifecycle: 
> http://developer.android.com/guide/components/activities.html#Lifecycle
>
> When you rotate your device your activity is completely shut down and then 
> re-created.  Thus, by default, it gets put in the same state as when you 
> first launch the app.
>
> To compensate for this, you need to override and implement the 
> onSaveInstanceState() and onRestoreInstanceState() methods to put your 
> activity in the same state it was before the rotation occurred.
>
>
> http://developer.android.com/reference/android/app/Activity.html#onSaveInstanceState%28android.os.Bundle%29
>
>
> http://developer.android.com/reference/android/app/Activity.html#onRestoreInstanceState%28android.os.Bundle%29
>
> Thanks,
> Justin Anderson
> MagouyaWare Developer
> http://sites.google.com/site/magouyaware
>
>
> On Sun, Jun 24, 2012 at 7:10 AM, StSch <[email protected]
> > wrote:
>
>> Can I please point you to my question on Stack Overflow?
>>
>>
>> http://stackoverflow.com/questions/11175966/how-to-prevent-the-layout-from-getting-reset-when-the-screen-orientation-changes
>>
>> I am a bit stuck. It's a pretty simple example, the checkbox's event
>> handler adds one button to the layout. I change the screen orientation
>> and the button disappears. The button that was added to the layount in
>> the onCreate()-method remains on the screen. What's the difference?
>> What do I need to do to still have Button 2 on the screen after I
>> change the screen orientation?
>>
>> Regards,
>> -Steffen-
>>
>> --
>> 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
>
>
>
Am Freitag, 29. Juni 2012 17:57:48 UTC+2 schrieb MagouyaWare:
>
> What do I need to do to still have Button 2 on the screen after I
>> change the screen orientation?
>>
>
> You need to read up on the activity lifecycle: 
> http://developer.android.com/guide/components/activities.html#Lifecycle
>
> When you rotate your device your activity is completely shut down and then 
> re-created.  Thus, by default, it gets put in the same state as when you 
> first launch the app.
>
> To compensate for this, you need to override and implement the 
> onSaveInstanceState() and onRestoreInstanceState() methods to put your 
> activity in the same state it was before the rotation occurred.
>
>
> http://developer.android.com/reference/android/app/Activity.html#onSaveInstanceState%28android.os.Bundle%29
>
>
> http://developer.android.com/reference/android/app/Activity.html#onRestoreInstanceState%28android.os.Bundle%29
>
> Thanks,
> Justin Anderson
> MagouyaWare Developer
> http://sites.google.com/site/magouyaware
>
>
> On Sun, Jun 24, 2012 at 7:10 AM, StSch <[email protected]
> > wrote:
>
>> Can I please point you to my question on Stack Overflow?
>>
>>
>> http://stackoverflow.com/questions/11175966/how-to-prevent-the-layout-from-getting-reset-when-the-screen-orientation-changes
>>
>> I am a bit stuck. It's a pretty simple example, the checkbox's event
>> handler adds one button to the layout. I change the screen orientation
>> and the button disappears. The button that was added to the layount in
>> the onCreate()-method remains on the screen. What's the difference?
>> What do I need to do to still have Button 2 on the screen after I
>> change the screen orientation?
>>
>> Regards,
>> -Steffen-
>>
>> --
>> 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
>
>
>
Am Freitag, 29. Juni 2012 17:57:48 UTC+2 schrieb MagouyaWare:
>
> What do I need to do to still have Button 2 on the screen after I
>> change the screen orientation?
>>
>
> You need to read up on the activity lifecycle: 
> http://developer.android.com/guide/components/activities.html#Lifecycle
>
> When you rotate your device your activity is completely shut down and then 
> re-created.  Thus, by default, it gets put in the same state as when you 
> first launch the app.
>
> To compensate for this, you need to override and implement the 
> onSaveInstanceState() and onRestoreInstanceState() methods to put your 
> activity in the same state it was before the rotation occurred.
>
>
> http://developer.android.com/reference/android/app/Activity.html#onSaveInstanceState%28android.os.Bundle%29
>
>
> http://developer.android.com/reference/android/app/Activity.html#onRestoreInstanceState%28android.os.Bundle%29
>
> Thanks,
> Justin Anderson
> MagouyaWare Developer
> http://sites.google.com/site/magouyaware
>
>
> On Sun, Jun 24, 2012 at 7:10 AM, StSch <[email protected]
> > wrote:
>
>> Can I please point you to my question on Stack Overflow?
>>
>>
>> http://stackoverflow.com/questions/11175966/how-to-prevent-the-layout-from-getting-reset-when-the-screen-orientation-changes
>>
>> I am a bit stuck. It's a pretty simple example, the checkbox's event
>> handler adds one button to the layout. I change the screen orientation
>> and the button disappears. The button that was added to the layount in
>> the onCreate()-method remains on the screen. What's the difference?
>> What do I need to do to still have Button 2 on the screen after I
>> change the screen orientation?
>>
>> Regards,
>> -Steffen-
>>
>> --
>> 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
>
>
>

-- 
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

Reply via email to