Here is the sample for you
showtab.xml
<?xml version="1.0" encoding="utf-8"?>
<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" >
<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" >
</TabWidget>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@android:id/tabcontent" >
</FrameLayout>
</LinearLayout>
</TabHost>
Below is the code of AfterLoginTabActivity(a tabactivity to be called)
public class AfterLoginTabActivity extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.afterloginview);
@SuppressWarnings("deprecation")
TabHost tabHost =getTabHost();
Intent i = new Intent(AfterLoginTabActivity.this,ProfileClass.class);
TabSpec profileSpec = tabHost.newTabSpec("profile").setIndicator("Profile").setContent(i);
Intent j = new Intent(AfterLoginTabActivity.this,GroupClass.class);
TabSpec groupSpec = tabHost.newTabSpec("group").setIndicator("group").setContent(j);
tabHost.addTab(profileSpec);
tabHost.addTab(groupSpec);
tabHost.setCurrentTab(1);
}
}
Code i used inside my button.setOnClickListener
if(msg == "success")
{
System.out.println("Inside button");
try {
Intent intent = new Intent(MainActivity.this,AfterLoginTabActivity.class);
startActivity(intent);
finish();
} catch (Exception e) {
// TODO: handle exception
System.out.print("tHIS IS EXCCEPTION" + e);
}
}