I have an activity which handles configuration changes. But now i have to change layout.I tried in onConfigurationChanged callback just to set again the layout and hoping will get the correct layout(land) but it's still showing the first layout for portrait view ( there two layout(same name) are placed in res/ layout and res/layout-land :)
if I delete android:configChanges="orientation", it works should be, but ı need to handle onConfigurationChanged. What should I do??
If you have your portrait layout main.xml
in /res/layout
and your landscape layout main.xml
in /res/layout-land
, and your onConfigurationChanged()
looks like this:
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
setContentView(R.layout.main);
...
...
...
}
And in your Manifest you should have android:configChanges="keyboardHidden|orientation"
Then it should work fine, as this does in my app. Is this what you are doing?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With