Search code examples
androidrotationonconfigurationchanged

using both layout-land and onConfigurationChanged()


I just want to change Layout when the device has been rotated. but I've found that onConfigurationChanged() must call onCreate() again using setContentView with separated layout named of *_land.xml

if(getActivity().getWindowManager().getDefaultDisplay().
getRotation() == Surface.ROTATION_0)
view = inflater.inflate(R.layout.fragment_layout, null);
else view = inflater.inflate(R.layout.fragment_layout_land, null);

Project is too big and there are many codes to fix If onCreate again without finish().

I'd like somebody help this.

Thank you.

-> onConfigurationChanged concept is keep layout I think


Solution

  • this is not no more interestes

    onConfigurationChanged() cannot be used with layout-land folder's machanism. That's because the callback concept is to keep Layout. So Activity which used the method should Inflate landscape Layout.