-2

In making the swipe tabbed layout as below prior to Android 5.0:

enter image description here

Simply required the code as:

@Override
public void onCreate(Bundle savedInstanceState) {
    final ActionBar actionBar = getActionBar();
    ...

    // Specify that tabs should be displayed in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create a tab listener that is called when the user changes tabs.
    ActionBar.TabListener tabListener = new ActionBar.TabListener() {
        public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
            // show the given tab
        }

        public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
            // hide the given tab
        }

        public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
            // probably ignore this event
        }
    };

    // Add 3 tabs, specifying the tab's text and TabListener
    for (int i = 0; i < 3; i++) {
        actionBar.addTab(
                actionBar.newTab()
                        .setText("Tab " + (i + 1))
                        .setTabListener(tabListener));
    }
}

But given the methods for navigation on the ActionBar are deprecated, How can I implement this type of view to be compatible withe Android 5.0 and previous versions?

Sauron
  • 6,399
  • 14
  • 71
  • 136
  • 1
    https://stackoverflow.com/questions/27461578/replacement-for-actionbar-navigation – CommonsWare Dec 16 '14 at 20:48
  • uh you already asked this and was provided with an answer – tyczj Dec 16 '14 at 20:51
  • possible duplicate of [Action bar navigation modes are deprecated in Android L](http://stackoverflow.com/questions/24473213/action-bar-navigation-modes-are-deprecated-in-android-l) – matiash Dec 16 '14 at 21:25
  • No, it is a different question. In https://stackoverflow.com/questions/27461578/replacement-for-actionbar-navigation i am address the basic tabs while in this question I am looking looking at the swipe views. – Sauron Dec 16 '14 at 21:35
  • 1
    @Sauron You want `ViewPager` + `Sliding Tabs`, you are using older design patterns. – Jared Burrows Feb 13 '15 at 04:35

1 Answers1

1

You need to update to Toolbar here is the documentation.

http://android-developers.blogspot.mx/2014/10/appcompat-v21-material-design-for-pre.html

JDeLeon92
  • 142
  • 3
  • 11