

main.xml
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<AnalogClock android:id="@+id/tabAnalogClock"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<DigitalClock android:id="@+id/tabDigitalClock"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</FrameLayout>
</LinearLayout>
</TabHost>
package com.exercise.AndroidTabWidget;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TabHost;
public class AndroidTabWidgetActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabs=(TabHost)findViewById(R.id.tabhost);
tabs.setup();
TabHost.TabSpec tabSpecAnalog = tabs.newTabSpec("tagAnalogClock");
tabSpecAnalog.setContent(R.id.tabAnalogClock);
tabSpecAnalog.setIndicator("Analog");
TabHost.TabSpec tabSpecDigital=tabs.newTabSpec("tagDigitalClock");
tabSpecDigital.setContent(R.id.tabDigitalClock);
tabSpecDigital.setIndicator("Digitl");
tabs.addTab(tabSpecAnalog);
tabs.addTab(tabSpecDigital);
}
}

1 comment:
cool app.
Post a Comment