应该使用什么而不是“setListNavigationCallbacks”?

时间:2021-08-06 10:43:47

Background

setListNavigationCallbacks is used to allow the user to switch between different views of the current screen easily via the ActionBar, as shown here and here.

setListNavigationCallbacks用于允许用户通过ActionBar轻松切换当前屏幕的不同视图,如此处和此处所示。

The problem

I've noticed it got deprecated as of API21 (Lollipop), and that all the documentation says is to look for other navigation solutions, but it doesn't say what's the best one that fits the same point:

我注意到它从API21(Lollipop)开始就被弃用了,并且所有文档都说要寻找其他导航解决方案,但它并没有说出哪一个最适合同一点的导航解决方案:

This method is deprecated. Action bar navigation modes are deprecated and not supported by inline toolbar action bars. Consider using other common navigation patterns instead.

不推荐使用此方法。不推荐使用操作栏导航模式,内联工具栏操作栏不支持。请考虑使用其他常见的导航模式。

All other functions/classes that are related to this function are also deprecated, such as setNavigationMode, OnNavigationListener, ActionBar.NAVIGATION_MODE_LIST .

与此函数相关的所有其他函数/类也不推荐使用,例如setNavigationMode,OnNavigationListener,ActionBar.NAVIGATION_MODE_LIST。

What I've tried

  1. The navigation drawer is for navigation of different screens, and not different views of the same screen.

    导航抽屉用于导航不同的屏幕,而不是同一屏幕的不同视图。

  2. adding an action item that will provide a way to switch between the modes, but that's a bit weird...

    添加一个动作项,提供一种在模式之间切换的方法,但这有点奇怪......

  3. using a ViewPager, but that's also weird as it doesn't really switch views, plus it takes more space.

    使用ViewPager,但这也很奇怪,因为它没有真正切换视图,而且需要更多的空间。

  4. Using tabs, but I think that's also deprecated in some way, plus it takes more space this way.

    使用制表符,但我认为它也以某种方式被弃用,而且这种方式需要更多空间。

The question

What should be the best alternative to this way of navigation?

什么应该是这种导航方式的最佳替代方案?

1 个解决方案

#1


1  

This post explains why not only list-, but ALL navigation modes have been deprecated. It became too difficult to make it able to customize Actionbar's navigations. Toolbar is the new Actionbar (also available in the appcompat-v7 support library). However, you won't find these methods there either. Instead, you need to supply your own optional (navigation) view(s). Then you can use it like a normal view in your layout.

这篇文章解释了为什么不仅列出,而且所有导航模式都已被弃用。让它能够自定义Actionbar的导航变得非常困难。工具栏是新的Actionbar(也可在appcompat-v7支持库中找到)。但是,您也不会在那里找到这些方法。相反,您需要提供自己的可选(导航)视图。然后,您可以像布局中的普通视图一样使用它。

#1


1  

This post explains why not only list-, but ALL navigation modes have been deprecated. It became too difficult to make it able to customize Actionbar's navigations. Toolbar is the new Actionbar (also available in the appcompat-v7 support library). However, you won't find these methods there either. Instead, you need to supply your own optional (navigation) view(s). Then you can use it like a normal view in your layout.

这篇文章解释了为什么不仅列出,而且所有导航模式都已被弃用。让它能够自定义Actionbar的导航变得非常困难。工具栏是新的Actionbar(也可在appcompat-v7支持库中找到)。但是,您也不会在那里找到这些方法。相反,您需要提供自己的可选(导航)视图。然后,您可以像布局中的普通视图一样使用它。