I am building an app that chang开发者_如何学运维es every time the user clicks on a button the text view changes and moves to another part of the activity...When the orientation is changed the view is destroyed and recreated.
How can i save it to be the same as it was before, and save the last button the user clicked, to put them back where they were.
You can subscribe the Sensor Events that will let you know when the orientation has been changed. When this event is fired fire all your data into a DataState object and send back to the Activity. When the activity is started up again it will check to see if the DataState object is not null and you can restore the state from that!
I am aware this answer is a bit jumbled but it is possible to do this. I'm just not sure on the specifics.
http://developer.android.com/reference/android/hardware/SensorManager.html
精彩评论