Search code examples
androidandroid-layoutandroid-fragmentstabsandroid-tabs

Official Android Swipe / Tabs Example Includes Deprecated Functionality: Is there an alternative sample?


I'm a long-time Windows developer who is now doing Android development. I would like to use the exact functionality contained in the following officially documented example on tabs and swipe: http://developer.android.com/training/implementing-navigation/lateral.html

Deprecated Functionality

However, the downloadable example contains methods & functionality which is deprecated.

I'm confused about why the Android official example which shows how to handle tabs and swiping ends up including code which is deprecated.

Is it not the most recent version?

What Functionality Am I Looking For?

I'll show you two screen shots which display tabs and allow the user to select the tabs to navigate among them or swipe left or right to move through them. Looks like the following: Tab 1 (main form) Tab 2 (main form)

I want the user to be able to easily switch between the two tabs and I have a plan to indicate to the user that information on the other tab has been updated by displaying an icon on the current tab.

My Main Question

Is there a similar example which does not include these deprecated methods?

Related Questions

If I choose to implement the code in my application -- because the solution is quite beautiful and looks easy to implement -- what will the consequences be?

  1. Does it mean that some time in the future the application wouldn't even work properly?
  2. Does it mean that it may not work on some devices (API versions)?

Here's some of the code which is deprecated:

actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() actionBar.setSelectedNavigationItem(position);

actionBar.addTab();

actionBar.newTab();


Solution

  • It seems that the deprecated functionality is actually related to the ActionBar.

    After quite a bit of searching, I found a better example of what I wanted -- sans ActionBar and sans deprecated functionality : http://developer.android.com/samples/SlidingTabsBasic/index.html

    When you get to that page, you will see that there is no documentation for the subject. It's odd. Look very closely in the upper right corner and you'll see a download link which will allow you to download a sample. It looks like: download link

    The sliding tab solution is even more elegant and does not include any deprecated functionality. Here's what it looks like: tabslider without deprecated functionality

    The example is fantastic, because you can traverse through the tabs by swiping the bottom panel. Or you can click any of the tabs to move to the associated tab.

    Also, the example gives you some more fucntionality above the tabs with the Show Log menu item which switches out the top portion. Definitely worth a look and this answers my question.

    Hope this helps someone else who is looking.