layout-land is not working?

若如初见. 提交于 2019-12-11 10:58:58

问题


I did some researches about this question but I couldn't find my answer. So, yes I did create a folder under res called "layout-land" and I put a separate main.xml in it. I intentionally deleted some images in the main.xml in the layout-land and I noticed that these images were still there when I rotated the android phone to horizontal.

Many questions similar to mine are caused by adding onConfigurationChanged to manifest. But I did NOT add anything to manifest as explained by this link

layout-land xml files does not work with onConfigurationChanged call back


回答1:


First thing you must check is whether you already have in your Manifest.xml android:configChanges="orientation" that means that you wish to control the state of your activity when the orientation changes. When there's an orientation change Android will destroy your activity and recreate new, so any data will be lost.

So you should use onConfigurationChanged() method or onRetainNonConfigurationInstance() method.

I recommend to you read some tutorial.



来源:https://stackoverflow.com/questions/10807846/layout-land-is-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!