I am doing a very basic layout inflation of a XML layout into a linear layout container. The inflation is working however when I rotate the view that was inflated disappears (as expected) what I want to know is there a way to save the inflation or view group such as through on save instance state so that I do not need to inflate again since I read layout inflation is expensive!
Asked
Active
Viewed 335 times
0
-
http://developer.android.com/guide/topics/resources/runtime-changes.html – Fatih Santalu Sep 28 '14 at 21:23
-
It says in the caution box that I should not pass views as they can leak – user3364963 Sep 28 '14 at 21:28
1 Answers
0
You shouldn't worry about View inflations being expensive at orientation change! This is how Android works, on orientation change your Activity gets recreated. Period.
But if you really need to (you probably don't), it is possible to force an Activity to not get recreated, in short use android:configChanges="orientation" in your manifest activity declaration. More about this here.
-
thanks, i'll just re-inflate the view because its only just one view anyway. – user3364963 Sep 28 '14 at 21:50
-
1Please don't use configChanges. If you don't know whether you should or not, you should not. http://developer.android.com/guide/topics/resources/runtime-changes.html – Eric Cochran Sep 28 '14 at 22:44