Reputation: 1050
Hi Everyone iam new to android and stuck with the orientation problem i need to display separate layout in landscape and portrait which i designed separately and placed in layout-large and layout-large-land folders now i need to change layout when device is rotated to landscape with out destroying and recreating the Activity
please help me get out of this problem
Thanks in Advance
Upvotes: 3
Views: 2040
Reputation: 5258
Replace
layout-large-land
with
layout-land-large
Prevent activity from recreating/destroying
Add attribute android:configChanges="orientation"
to the activity declaration in the AndroidManifest.xml
file.
The purpose of the android:configChanges
attribute is to prevent an activity from being recreated when it's really required.
Let me know if it works for you..
Upvotes: 0
Reputation: 3261
Try this,
Add this code in your mainfest.xml each and every activity.
android:ConfigChanges="keyboardHidden|orientation"
Upvotes: -1
Reputation: 39836
my advice as a long time Android programmer is:
Don't do it!
Let the activity be destroyed and re-built with the correct layout.
Just search and research on all the several methods of keeping the data during orientation changes and apply them to your specific case. Below a few to illustrate:
onCreate(Bundle)
receives that bundle that contains information saved during onSavedInstances(Bundle);setRetainInstance(true)
and use it to remember the dataUpvotes: 3