CopyPastor

Detecting plagiarism made easy.

Score: 0.8161356997652858; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2014-06-24
by Farouk Touzi

Original Post

Original - Posted on 2010-05-25
by Janusz



            
Present in both answers; Present only in the new answer; Present only in the old answer;

You are losing the list items because the default behavior for android during orientation change is to destroy your activity and recreate it. This behavior is chosen to enable android to recreate the activity with a new layout that may be used especially for the new orientation.
To prevent your list items from disappearing there are several thing that have to be done. The first thing that helps during orientation change is to simply reuse the same activity after the change. This can be done through adding this line in your manifest :
android:configChanges="keyboardHidden|orientation"
It hand off to your onConfigurationChanged() method, if you don't supply one it just does nothing other than re-measure the layout, which seems to be a perfectly adequate way of handling the rotate most of the time.
You are losing the list items because the default behavior for android during orientation change is to destroy your activity and recreate it. This behavior is chosen to enable android to recreate the activity with a new layout that may be used especially for the new orientation.
To prevent your list items from disappearing there are several thing that have to be done. The first thing that helps during orientation change is to simply reuse the same activity after the change. This can be done through adding this line
android:configChanges="keyboardHidden|orientation"
to the activity tag in your manifest you are experiencing the problem with. This is explained in more detail in this [question][1].
The behavior you explained will likely also appear if the user opens the activity and then sends your application to the background does many other memory heavy stuff to get your application removed from memory and then revisits your app. If this is the case you have to overwrite the onSaveInstanceState method in you activity. How to this is explained in this [question][2].

[1]: https://stackoverflow.com/questions/2620917/how-to-handle-an-asynctask-during-screen-rotation [2]: https://stackoverflow.com/questions/151777/how-do-i-save-an-android-applications-state

        
Present in both answers; Present only in the new answer; Present only in the old answer;