Android Tab Host and Tab Widget
Tabs make users easy to switch between different views or functional aspects of an application. In this example, I will show how to add simple android tabs to your app using XML tabhost and tabwidget. In this example, I will place three tabs and different content and color in tabs.
Application Name: TabHost Example
Company Domain: viralandroid.com
Package Name: com.viralandroid.tabhostexample
Minimum SDK: Android 2.2 (API 8 Froyo)
At first, you have to add TabHost, TabWidget, FrameLayout to your XML activity layout. Aftrer adding TabHost, TabWidget and FrameLayout, your XML file looks like this.
res/layout/activity_main.xml
To make working perfectly, you have to add little bit code to your java file and final modified code of java activity file looks like this.
src/MainActivity.java
Create a new Android Project
Application Name: TabHost Example
Company Domain: viralandroid.com
Package Name: com.viralandroid.tabhostexample
Minimum SDK: Android 2.2 (API 8 Froyo)
Add TabHost in XML Activity Layout
At first, you have to add TabHost, TabWidget, FrameLayout to your XML activity layout. Aftrer adding TabHost, TabWidget and FrameLayout, your XML file looks like this.
res/layout/activity_main.xml
Modify your Java Activity
To make working perfectly, you have to add little bit code to your java file and final modified code of java activity file looks like this.
src/MainActivity.java
No comments: