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