Search code examples
androidtabsandroid-viewpagerswipe

Swipe Views with Tabs


I'm trying to make a swipe views with tabs, and I found a lot of examples that works, but, I would like to work with actual elements and not deprecated like:

  • actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS)

  • actionBar.setSelectedNavigationItem(position);

  • actionBar.addTab(...)


Solution

  • If switch to the android support library is an option for you then you can use the new TabLayout.

    See an example implementation here: http://blog.grafixartist.com/material-design-tabs-with-android-design-support-library/

    If his is not an option you can take a look at the android developer sample called 'SlidingTabsBasic' which provides a tab control.

    https://developer.android.com/samples/SlidingTabsBasic/index.html