I am having trouble setting up landscape mode in my application.
I have a /res folder that contains a layout folder and a layout-land folder
layout
-----main.xml
layout-land
-----main.xml
My /layout-land/main.xml contains different UI elements than /layout/main.xml. How can I map each layout appropriately when the user has switched to landscape mode and vice versa?
I am basically displaying a full screen ImageView when the user switches to landscape mode. The ImageView will download an image from the internet and display it. Switching back to portrait, should simply go back to my portrait mode, which has a different set of UI components.
I get a crash when I switch to landscape mode:
because I can’t get the id:
chartImageViewLandscape = (ImageView) this.findViewById(R.id.chartImageViewLandscape);
chartImageViewLandscape is in /layout-land/main.xml
How can I get a reference to this?
Sheehan, regarding onRetainNonConfigurationInstance(), below is what I am currently doing for my app in progress. I have the feeling I’m overcomplicating it though, I think there’s a simpler way; however, this works just fine for me currently:
So in my activity class “RotationMenu.java”:
Now, in my onCreate(Bundle savedInstanceState) method:
Again, this is how I am doing it currently. If anyone knows of a more efficient method, by all means comment. 🙂