Search code examples
androidandroid-tabs

Implement Android Tabs without actionBar.newTab()


I am new to Android Development, and I am implementing some basic programs. My minimum SDK is KitKat.

I want to create an App which has multiple tabs. I am using the following approach:

ActionBar actionBar = getActionBar();
actionBar.newTab().setText("Tab1");
actionBar.newTab().setText("Tab2");

But these methods are deprecated in Android Studio now.

How do I get the exact implementation of this code according to new methods?

PLEASE EXPLAIN IN DETAIL.

www.developer.android.com is very complicated for me.


Solution

  • If you want android tabs that look like the ones in Googles Updated apps like the Play store then you would have to use ViewPager and two java files from Googles open source I/O 2014 app.

    If you are a beginner, I recommend not using android developer website for common things like android tabs because they just make it too much over complicated and its almost like Computer science degree, you only use 40% of what you learn. There is hundreds of tutorials websites and blogs out there that will show you how to do the same thing but in a much more digestible way :D