Android ActionBar Tabs Example
http://www.viralandroid.com/2015/09/android-actionbar-tabs-example.html
Android ActionBar was introduced from API level 11. In this example, I will show how to add simple android action bar tabs to your application. At last, I have provided GitHub link to download complete source code of this example project.
Related:
Android Material Design Sliding Tabs Example
Animated Android Folding Tab Bar Menu Example
Android Material Design Tabs Using TabLayout
Application Name: ActionBar Tab Example
Company Domain: viralandroid.com
Package Name: com.viralandroid.actionbartabexample
Minimum SDK: Android 2.2 (API 8 Froyo)
To add tabs in the action bar of your app, you have to implement ActionBar.TabListener in your java activity. And your java activity file looks like this.
src/MainActivity.java
To show different content in different tabs, you have to create XML layout for different tabs. Following are the three XML activity layouts for three action bar tabs, actionbar_tab_1.xml for tab 1, actionbar_tab_2.xml for tab 2 and actionbar_tab_3.xml for tab 3.
And also, your main XML activity layout looks like this.
res/layout/activity_main.xml
That’s all. Now run your application. The final result is shown below.
Related:
Android Material Design Sliding Tabs Example
Animated Android Folding Tab Bar Menu Example
Android Material Design Tabs Using TabLayout
Create a new Android Project
Application Name: ActionBar Tab Example
Company Domain: viralandroid.com
Package Name: com.viralandroid.actionbartabexample
Minimum SDK: Android 2.2 (API 8 Froyo)
Add Tabs to Your Activity
To add tabs in the action bar of your app, you have to implement ActionBar.TabListener in your java activity. And your java activity file looks like this.
src/MainActivity.java
Create Three XML Layout for Tabs
To show different content in different tabs, you have to create XML layout for different tabs. Following are the three XML activity layouts for three action bar tabs, actionbar_tab_1.xml for tab 1, actionbar_tab_2.xml for tab 2 and actionbar_tab_3.xml for tab 3.
And also, your main XML activity layout looks like this.
res/layout/activity_main.xml
That’s all. Now run your application. The final result is shown below.
Android ActionBar Tabs |
Download Complete Example Project
Download complete Android ActionBar Tabs Example project source code from GitHub.