Exercise: Changing screen orientation means loss of state

When you change screen orientation (press Ctrl F11 in the emulator) your activity basically stops and recreates. This means that and activity state might loose its state.

Problem: Change screen orientation means loss of state

Go back to your solution to the FIRST version of the collect words exercise.

Run the application, enter and save a few words, press the Show button to see that the words are really saved .

Now try to change the screen orientation: Press the Show button again.
The list of words is now empty, because the change of screen orientation destroyed and recreated the activity.

This is a general problem that needs a general solution!

Solution: Persisting the state using life cycle methods

Use the methods onSaveInstanceState and onRestoreInstanceState http://developer.android.com/training/basics/activity-lifecycle/recreating.html

Horizontal layout of buttons

The buttons in your application should be shown like

Hint: Two LinearLayout's, one inside the other. The outermost (red) has android:orientation="vertical". The innermost (green) has android:orientation="horizontal".

Each button should has the same amount of space. Hint: android:layout_weight="something"