简体   繁体   English

从后台删除片段

[英]Delete Fragment from backstack

I have a problem with cleaning of backstack. 我有清洁后盖的问题。 I call from Fragment A the Fragment B with : 我从片段A调用片段B:

 transaction = fragmentManager.beginTransaction();
                    transaction.replace(((ViewGroup)(getView().getParent())).getId(), ScarsdaleScelta.newIstance());
                    transaction.addToBackStack(null);
                    transaction.commit();

The problem is that if in Fragment BI use navigation drawer and I change fragment without use the back button , the Fragment A remains in the backstack! 问题是,如果在Fragment BI中使用导航抽屉,而我在不使用后退按钮的情况下更改了片段,则Fragment A仍留在后堆栈中! So if I press the back button the Fragment A overlaps the other Fragment. 因此,如果按“后退”按钮,片段A与另一个片段重叠。

手动导航时,您可以自己从后堆栈中删除片段:

getFragmentManager().popBackStack();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM