简体   繁体   English

使用导航控制器时如何将操作栏添加到主屏幕?

[英]How to add Action bar to main screen when using navcontroller?

I am creating a project in which i would like to have following phenomenon.我正在创建一个项目,我想在其中出现以下现象。 The first activity can be launched from an intent.第一个活动可以从一个意图启动。 When it is launched it has a back button on action bar.当它启动时,它在操作栏上有一个后退按钮。 There are further destinations from this activity which i have set up using navcontroller.我使用 navcontroller 设置了此活动的更多目的地。 I have set up actionbar with navcontroller.我已经用导航控制器设置了动作栏。 But it removes the back button from main screen.但它从主屏幕上删除了后退按钮。 What should i do to achieve desired result?我应该怎么做才能达到预期的效果?

Try to enable the back button on action bar in your main activity:尝试在您的主要活动中启用操作栏上的后退按钮:

 supportActionBar?.setDisplayHomeAsUpEnabled(true)

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

相关问题 如何删除操作栏和主屏幕之间的线? - How can I remove the line between the action bar and the main screen? 使用 NavController 时如何使用 newInstance() 创建片段? - How to create fragments with newInstance() when using NavController? 在Android上使用片段布局时,如何正确禁用主要片段的操作栏setDisplayHomeAsUpEnabled? - How to proper disable action bar setDisplayHomeAsUpEnabled for main fragment when using fragment layouts on android? 如何使用 navController 在 Jetpack Compose 中从一个屏幕导航到另一个屏幕? - How to navigate from a screen to another in Jetpack Compose using navController? 如何添加操作栏 - How to add action bar 使用 NavController 时如何返回上一个片段? - How do you return to the previous fragment when using a NavController? 在Android中删除操作栏和主屏幕之间的线条或分隔线 - Removing line or divider between action bar and main screen in Android 未显示在屏幕上时,Android Fragment会贡献给操作栏 - Android Fragment contributes to the Action Bar when not on the screen 如何在屏幕中心而不是动作条中心对齐动作条标题 - How to align action bar title in center of screen, not the center of action bar 如何将搜索添加到操作栏中 - How to add search into action bar
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM