On Sun, Jun 24, 2012 at 8:10 AM, StSch
<[email protected]>wrote:

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

The difference is one is add in onCreate, which is called again when the
Activity is recreated, and the other is called dynamically on click of a
button, which of course does not get called again.

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

Unfortunately, that's how it's done. Either that or handle the
configuration changes yourself, which is a whole other can of worms.

What I would do is have a business model object that describes your UI.
Instead of modifying your UI on clicking a button, you update your model
and build your UI off of that. When you change configuration, persist the
model (as a Bundle, as a static, whatever) and recreate your UI from it as
necessary.

-------------------------------------------------------------------------------------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices

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