Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should be used instead of "setListNavigationCallbacks"?

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.

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:

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 .

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.

  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?

like image 300
android developer Avatar asked Oct 22 '14 07:10

android developer


People also ask

What is the action bar in Android?

Android ActionBar is a menu bar that runs across the top of the activity screen in android. Android ActionBar can contain menu items which become visible when the user clicks the “menu” button.


1 Answers

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.

like image 54
Coen B Avatar answered Oct 16 '22 20:10

Coen B