gpt4 book ai didi

android - 使用全屏 fragment 提交 fragment 事务

转载 作者:行者123 更新时间:2023-11-29 02:29:52 25 4
gpt4 key购买 nike

我有一个 fragment ( fragment A),它不是全屏,我想在不知道容器 ID 的情况下从它打开另一个充满整个屏幕的 fragment ( fragment B)

单击以下链接可查看阐明情况的图像

Fragment A open Fragment B

最佳答案

你的 Activity 应该管理 fragment 通信

Often you will want one Fragment to communicate with another, for example to change the content based on a user event. All Fragment-to-Fragment communication is done through the associated Activity. Two Fragments should never communicate directly.

To allow a Fragment to communicate up to its Activity, you can define an interface in the Fragment class and implement it within the Activity. The Fragment captures the interface implementation during its onAttach() lifecycle method and can then call the Interface methods in order to communicate with the Activity.https://developer.android.com/training/basics/fragments/communicating

关于android - 使用全屏 fragment 提交 fragment 事务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50107229/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com