布局土地不起作用? [英] layout-land is not working?

查看:98
本文介绍了布局土地不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对此问题进行了一些研究,但找不到答案.因此,是的,我确实在res下创建了一个名为"layout-land"的文件夹,并在其中放置了一个单独的main.xml.我有意删除了布局区域main.xml中的一些图像,当我将android手机旋转到水平位置时,我注意到这些图像仍然存在.

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.

许多与我的问题类似的问题是由于在清单中添加onConfigurationChanged引起的.但我没有按照此链接的说明添加任何内容来显示

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文件不与onConfigurationChanged回调一起使用

推荐答案

您必须检查的第一件事是您是否已经在Manifest.xml android:configChanges="orientation"中,这意味着您希望在定向时控制活动状态变化.更改方向后,Android会破坏您的活动并重新创建新活动,因此所有数据都将丢失.

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.

因此,您应该使用onConfigurationChanged()方法或onRetainNonConfigurationInstance()方法.

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

我建议您阅读一些教程.

I recommend to you read some tutorial.

这篇关于布局土地不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆