6

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?

android developer
  • 114,585
  • 152
  • 739
  • 1,270
  • I wouldn't worry about it too much for now, but I would put an extra handler class in between your navigation and your application classes so you can switch it out later. It could take minutes or months before someone documents this. – G_V Oct 22 '14 at 08:04
  • 1
    @user3427079 It's annoying though. About 90% of the times when I see "deprecated" on the documentation, it doesn't say why, and what to use instead. Then usually what I do is search the Internet, and even there I can't find a solution. – android developer Oct 22 '14 at 08:37
  • True, these updates and changes come so fast that it's near impossible to follow them properly. However, android is made to be backwards compatible very far back so it usually isn't much of a problem. Annoying things like phasing out the hardware menu buttons only happen once in a long while. I think once android L devices hit the market, it will become clearer but for now there isn't much you can do besides creating a facade to make it easier to swap later. – G_V Oct 22 '14 at 09:57
  • @user3427079 No need for special design patterns as the handling is very short and calls other functions via the listener. I guess that even though it's deprecated it will still work fine there. I'll still keep this question open so that maybe people who know the answer (now or in the future) will be able to answer it. – android developer Oct 22 '14 at 11:12
  • @androiddeveloper I also noticed that they use a `Spinner` in the `ActionBar` in the `Google IO 2014` app. – theblang Oct 23 '14 at 21:26
  • @mattblang So what gives? I just don't get this deprecation that Google puts on so many classes, and without any explanations... – android developer Oct 23 '14 at 21:28
  • @androiddeveloper Yeah, I don't know. At least, like user3427079 mentioned, it probably won't really matter. My only guess is that they want you to use the `Toolbar API`? That is what they are doing in `activity_browse_sessions.xml` in the `IO` app. – theblang Oct 23 '14 at 21:36
  • This questions was answered here: http://stackoverflow.com/questions/26510930/android-lollipop-add-popup-menu-from-title-in-toolbar – Pablo Nov 27 '14 at 20:59
  • @Pablo This is nice, but that's not what I've asked. I asked what should be used instead, as this has become deprecated. – android developer Nov 27 '14 at 21:12

1 Answers1

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.

Coen B
  • 725
  • 5
  • 12