简体   繁体   English

您最近是否不鼓励使用导航组件?

[英]Have you recently discouraged using naviation component?

I am using bottom navigation for single activity .我正在为single activity使用bottom navigation

What I'm trying to do is do various screen transitions through the bottom menu ( fragment ).我要做的是通过bottom menufragment )进行各种屏幕转换。 And we are implementing a function to switch screens without moving the menu on the switched screen.我们正在实施 function 来切换屏幕,而无需移动切换屏幕上的菜单。

I've considered using the BottomNavigation Activity provided by Android (probably the JetPack navigation component ).我考虑过使用 Android (可能是JetPack navigation component )提供的BottomNavigation Activity

However, I saw that there were many problems with this component.但是,我看到这个组件有很多问题。 Especially the NavController .特别是NavController

For example, when i switch screens and then come back, i have to manually restore the view state.例如,当我切换屏幕然后返回时,我必须手动恢复视图 state。

Because NavController uses replace() instead of show/hide , so I've been told so因为NavController使用replace()而不是show/hide ,所以有人告诉我

In addition to these problems, using FragmentManager and show/hide is more recommended, is it true?除了这些问题,更推荐使用FragmentManagershow/hide ,是真的吗?

So I'm currently using setOnNavigationItemSelectedListener , but it's actually more difficult because I'm implementing the screen transition myself.所以我目前正在使用setOnNavigationItemSelectedListener ,但实际上更困难,因为我自己实现了屏幕转换。

I would definitely use the provided NavController if I was you.如果我是你,我肯定会使用提供的 NavController。

It has had its issues over the years, some of them which you are describing.多年来,它一直存在问题,您正在描述其中一些问题。 Most of these problems were removed in version 2.4.0-alpha01 .大多数这些问题已在2.4.0-alpha01 版本中删除。 Version 2.4.0-alpha02 is also out now. 2.4.0-alpha02 版现在也发布了。

Check out this sample to see the BottomNavigationView in action, together with the new NavController.查看示例以查看运行中的 BottomNavigationView 以及新的 NavController。 It is a great starting point for any app.对于任何应用程序来说,它都是一个很好的起点。

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

相关问题 在底部导航栏上重新选择操作 android 与导航组件 - Reselect operation on Bottom Naviation bar android with naviagtion component 导航抽屉调用活动 - Naviation Drawer calling an activity ActionBar列表导航与替代显示 - ActionBar list naviation with alternative display 为什么不鼓励在Android中使用字符串文字? 还有哪些其他/更好的选择? - Why is using string literals in Android discouraged? What other/better alternatives are available? 最近迁移到androidx,我发现了alertdialog的布局问题 - Migrate to androidx recently and I have discovered a layout problem with alertdialog 使用LibGDX,如何使用单独的图像制作动画? - Using LibGDX, how do you have an animation using seperate images ? 使用Intents打开最近写入的文件 - Opening a recently written file using Intents Flutter Firestore 如何显示我最近聊天的人的列表 - Flutter Firestore how to show the list of people i have recently chat with Android:最近使用媒体商店添加了歌曲列表 - Android:Recently Added songs list using media store 使用 Room 库获取最近插入的行 ID - Fetch recently inserted row id using Room library
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM