Simple Android TabHost and TabWidget Example

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.

Simple Android TabHost and TabWidget Example

Android Material Design Sliding Tabs Example
Android ActionBar Tabs Example
Android Material Design ActionBar/App Bar: How to Make Custom ActionBar

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.

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.

Now, runs your TabHost application which will look like screenshot below.

Android TabHost Example

Download Complete Example Project

Download complete Android TabHost and TabWidget Example project source code from GitHub.
Tutorial 8871225735204353758
Home item