简体   繁体   English

我如何显示和隐藏两个片段

[英]how can i show and hide two fragments

I have main activity in which list fragment is shown when the app is launched, then there is floatingbutton in list fragment when that button is clicked it opens next fragment (adding fragment) and there is again one more button in adding fragment when it is liked then again list fragment is shown in the main activity . 我的主要活动是在启动应用程序时显示list fragment ,然后单击该按钮时, list fragment出现floatingbutton按钮,它将打开下一个片段(添加片段),并且在喜欢时还会再添加一个按钮然后再次在主活动中显示列表片段。

Now I want that when the floating button of list fragment is clicked then list fragment should hide and adding fragment should show and when the floating button of adding fragment is clicked then adding fragment should hide and list fragment should show. 现在,我希望当单击列表片段的floating button ,应隐藏列表片段并显示添加片段;当单击添加片段的浮动按钮时,应隐藏并添加列表片段。

How can I do this thing using hide and show a method of fragment class? 我该如何使用隐藏和显示片段类的方法来做这件事?

how should I call these methods in both fragments when the floating buttons in both fragments are clicked. 单击两个片段中的浮动按钮时,如何在两个片段中调用这些方法。

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

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