Android的片段添加,但不可见 [英] android Fragment Added but not visible

查看:122
本文介绍了Android的片段添加,但不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前面临的一个问题,我无法理解。
这里的情况是:
我有一个包含一个主片段的FragmentActivity。
这里面的片段有3个片段,每个人把它放在自己的布局里面,一见钟情所有可见。事实上,他们是这样的:

I'm currently facing an issue I cannot understand. The situation here is : I have a FragmentActivity which contains a Main fragment. Inside this fragment there are 3 fragments, each one placed inside it's own layout, all visible at first sight. In fact they are like this :

A | B | C |

A|B|C|

要添加和更换这些布局我使用childFragmentManager里面的片段。
当我使用它的一切工作正常。但是,当我改变了设备的方向,则不会显示该片段,但增加(isAdded()方法返回真)并没有显示任何错误。

To add and replace the fragments inside these layouts I'm using the childFragmentManager. Everything works fine when I'm using it. But when I'm changing the device orientation, the fragment is not displayed but is added (isAdded() method return true) and no error is shown.

注:我更换有关片段时,方向改变,所以我真的不明白的问题可能是什么

Note : I'm replacing the concerned fragments when the orientation is changed so I really don't understand what the problem may be.

感谢您提前为你的答案。

Thank you in advance for your answer.

推荐答案

由于Android的加入。configChanges =keyboardHidden |方向|屏幕尺寸的作品

Thanks adding android:configChanges="keyboardHidden|orientation|screenSize" works.

这篇关于Android的片段添加,但不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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