android -Fragments - onConfigurationChanged -it's possible to change only the layout?

1k views Asked by At

I have a question related to fragments, the only solution to change the fragment layout it's if I remove the old instance and replace with new one? I have two layout's one for portrait and one for landscape - I want to keep all the information's(data) and only replace the layout the onConfigurationChanged() method is called, but I can't force the fragment to recreate the layout.

Thanks, Lorand

1

There are 1 answers

0
Nhat Nam NGUYEN On

I don't know whether you can only change your layout without reloading your data. My solution is Don't put android:configuration='orientation' in the manifest.xml.

When rotating screen, normally onCreateActivity will be call and it'll take the good layout AND RELOAD your data.