Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use TabHost.OnTabChangeListener in android?

Tags:

android

How to use TabHost.OnTabChangeListener in android?

give me some example code... :(

thanks

like image 691
Praveen Avatar asked Feb 11 '10 09:02

Praveen


People also ask

How to use TabHost in Android Studio?

The user can scroll tabs from left to right or right to left. This example demonstrates how to use tab host in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.

Which are the two child of the TabHost?

TabHost consists of two children of which one is FrameLayout (which is used to show the contents of the activity) and another one is TabWidget.

What is TabHost?

In Android, TabHost is a Container for tabbed window view. This object holds two children one is set of tab labels that the user clicks to select a specific tab and other is a FrameLayout object that displays the content of that page.


1 Answers

why it would be my pleasure to help you good sir:

myTabHost.setOnTabChangedListener(new OnTabChangeListener(){ @Override public void onTabChanged(String tabId) {     if(TAB_1_TAG.equals(tabId)) {         //destroy earth     }     if(TAB_2_TAG.equals(tabId)) {         //destroy mars     } }}); 

Where TAB_1_TAG is the tag provided to the newTabSpec method when creating the tab.

like image 138
pgsandstrom Avatar answered Oct 07 '22 23:10

pgsandstrom