添加具有add()方法一个片段不隐藏previous片段 [英] Adding a Fragment with add() method doesn't hide previous fragments

查看:186
本文介绍了添加具有add()方法一个片段不隐藏previous片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到的时候使用add()方法添加一个新片段意外情况。

I'm experiencing "unexpected behaviour" when using add() method to add a new fragment.

我想添加一个新片段上的FrameLayout,但是当我做了previous片段剧照可见。

I want to add a new fragment on a FrameLayout, but when I do it the previous fragment stills visible.

  • 这在使用add()方法是预期的结果?

  • Is this the expected result when using add() method?

这是因为我使用的是的FrameLayout和add()方法只需将片段在的FrameLayout不影响previous一个?

It is because I am using a FrameLayout and add() method just place a fragment over the FrameLayout without affect the previous one?

THX

推荐答案

不是一个错误。尝试更换(..)。而不是添加到后面堆栈(如果需要)。

Not a bug. Try replace(..). instead adding to the back stack if required.

修改我觉得用替换删除()加(​​)将解决你的问题,而是你突出你的相关的<一个href="http://stackoverflow.com/questions/6250580/fragment-already-added-illegalstateexception">post有哪些体现你特定环境下的一个错误。

EDIT I think that using replace or remove() add() will solve your problem but as you highlight in your related post there is a bug which manifests itself under your particular set of circumstances.

这篇关于添加具有add()方法一个片段不隐藏previous片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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