| || |
Re: [Chatter] "Where everybody knows your name ..."
I absolutely hate having to deal with this, and I'm coming from a developer's point of view. When an Android device's orientation changes, the foreground application's activities are destroyed and re-created. When this happens, Android uses two things to re-create it. First, it uses the default XML layout defined for that activity. Second, it uses a set of "saved state" information to preserve the exact state the activity was in (such as entered text). You get the same basic screen, re-created for the new screen dimensions. The problem with this is that, in some instances, actions taken out programmatically (such as adding layout elements at runtime) may not be correctly carried across this rotation behavior.
Originally Posted by cole2kb
If any of you run into applications with this oversight in the future, shoot the developer an email/leave them feedback. Include a link to this page, or paraphrase this quote:
My guess is that the View holding your attachment's information and thumbnail was not given an ID because it was assigned programmatically. Thus, the view is essentially "lost" in the rotation. I tried to keep this from being really technical (this is chatter, after all), but if anyone is really interested let me know. Caution:
Your activity will be destroyed and recreated each time the user rotates the screen. When the screen changes orientation, the system destroys and recreates the foreground activity because the screen configuration has changed and your activity might need to load alternative resources (such as the layout).
By default, the system uses the Bundle instance state to save information about each View object in your activity layout (such as the text value entered into an EditText object). So, if your activity instance is destroyed and recreated, the state of the layout is restored to its previous state with no code required by you. However, your activity might have more state information that you'd like to restore, such as member variables that track the user's progress in the activity. Note:
In order for the Android system to restore the state of the views in your activity, each view must have a unique ID, supplied by the android:id attribute.