http://www.edumobile.org/android/android-beginner-tutorials/tab-control/
and
http://www.codeproject.com/Articles/107693/Tabbed-Applications-in-Android
and
http://kandroid.wordpress.com/2011/05/28/tabview-part-1-simple-tab-control-in-android/
SAME activity----
XML
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
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"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/taba1"
android:orientation="vertical"
android:paddingTop="60px"
>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/taba2"
android:orientation="vertical"
android:paddingTop="60px"
>
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</FrameLayout>
</TabHost>
java..
import android.app.Activity;
import android.app.TabActivity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
@SuppressWarnings("deprecation")
public class MainActivity extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TabHost tabHost = getTabHost();
TabSpec spec1=tabHost.newTabSpec("Tab 1");
spec1.setContent(R.id.taba1);
spec1.setIndicator("Tab 1");
TabSpec spec2=tabHost.newTabSpec("Tab 2");
spec2.setIndicator("Tab 2");
spec2.setContent(R.id.taba2);
tabHost.addTab(spec1);
tabHost.addTab(spec2);
}
}
.................
new activites
tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("TEXT").setContent(new Intent(this, OptionsActivity.class)));
// tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("LIST").setContent(new Intent(this, et.class)));
// tabHost.setCurrentTab(0);
and
http://www.codeproject.com/Articles/107693/Tabbed-Applications-in-Android
and
http://kandroid.wordpress.com/2011/05/28/tabview-part-1-simple-tab-control-in-android/
SAME activity----
XML
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
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"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/taba1"
android:orientation="vertical"
android:paddingTop="60px"
>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/taba2"
android:orientation="vertical"
android:paddingTop="60px"
>
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</FrameLayout>
</TabHost>
java..
import android.app.Activity;
import android.app.TabActivity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
@SuppressWarnings("deprecation")
public class MainActivity extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TabHost tabHost = getTabHost();
TabSpec spec1=tabHost.newTabSpec("Tab 1");
spec1.setContent(R.id.taba1);
spec1.setIndicator("Tab 1");
TabSpec spec2=tabHost.newTabSpec("Tab 2");
spec2.setIndicator("Tab 2");
spec2.setContent(R.id.taba2);
tabHost.addTab(spec1);
tabHost.addTab(spec2);
}
}
.................
new activites
tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("TEXT").setContent(new Intent(this, OptionsActivity.class)));
// tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("LIST").setContent(new Intent(this, et.class)));
// tabHost.setCurrentTab(0);