如何在活动和碎片之间共享工具栏?

发布于 2025-02-13 02:06:27 字数 528 浏览 0 评论 0 原文

我的应用程序在全球范围内仅使用一个活动,所有导航组件都在此 Activity 中。

我有一个要求,在选择 list fragment 中的项目后,工具栏应该输入选定的模式。如下:

“在此处输入图像描述”

如何实现此模式开关?

My application uses only one Activity globally, and all the navigation components are in this Activity.

I have such a requirement that after selecting an item in ListFragment, Toolbar should enter selected mode. as follows:

enter image description here

enter image description here

How to achieve this mode switch?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

原谅过去的我 2025-02-20 02:06:27

我们可以使用 actionMode ,指南: https ://developer.android.com/guide/topics/ui/menus.html#cab

如果您使用 startActionMode fragment 中使用 actionmode ,然后在 activity 中关闭它,则可以覆盖 活动> code>中的OnActionModestarted 函数并获得 actionmode

Mofity ActionMode 样式:如何指定黑暗动作模式与我的主题

谢谢@darshan

We can use ActionMode, the guide: https://developer.android.com/guide/topics/ui/menus.html#CAB

If you use startActionMode to use ActionMode in the Fragment, and close it in Activity, you can override onActionModeStarted function in Activity and get ActionMode.

Mofity ActionMode style: How to specify dark action mode with my theme

Thank you for @DarShan

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文