Click here to Skip to main content
15,889,861 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear sir,

I define different templates(two main.xml files) one for portrait and one for landscape.

When I change screen from portrait to landscape or vice-versa, then application loaded the main.xml define in layout-land folder but this main.xml not loading state full data that portrait's main.xml was showing previously..

Eg. for more clearity --- suppose i have an imageview and a button in our application,and i false imageview's visiblity on button click.
now i launch this application on emulator and click the button ,at this time image's visiblity is false.

Now i switch the screen in landscape mode ,here image's visiblity should be false but it is not(it is showing the image).
How can I solve it?

Please help me,

Thank you,

Vishnu Jangid
Posted
Updated 21-Aug-11 19:02pm
v4
Comments
Dalek Dave 19-Aug-11 3:33am    
Edited for Grammar, Syntax and Readability.
Richard MacCutchan 21-Aug-11 15:14pm    
I have deleted your duplicate of this question; if anyone knows the solution they will post it here.

1 solution

This is because when the orientation changes Android actually finishes the activity and then creates a new one for the new orientation.

You need to save the state and then reload it when the next activity is created.
This can be done by overriding the onSaveInstanceState and onRestoreInstanceState functions.

A quick Google and I got this which should help you further.
http://stackoverflow.com/questions/151777/how-do-i-save-an-android-applications-state[^]

I hope this helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900