Я хочу загрузить tab3 при загрузке, но он загружает tab3 с содержимым tab1. Ниже приведен код, который я делаю для загрузки 3 вкладок, и я хочу, чтобы вкладка 3 загружалась 1-й.
package sh.mkt;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
public class thirdtab extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost);
TabSpec firstTabSpec = tabHost.newTabSpec("tid1");
TabSpec secondTabSpec = tabHost.newTabSpec("tid2");
TabSpec thiredTabSpec = tabHost.newTabSpec("tid3");
firstTabSpec.setIndicator("Buying Cost").setContent(new Intent(this,tab1.class));
secondTabSpec.setIndicator("Selling Cost").setContent(new Intent(this,tab2.class));
thiredTabSpec.setIndicator("Portfolio").setContent(new Intent(this,tab3.class));
tabHost.addTab(firstTabSpec);
tabHost.addTab(secondTabSpec);
tabHost.addTab(thiredTabSpec);
tabHost.getTabWidget().setCurrentTab(2);
}
}
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"
android:padding="5dp">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal"
android:layout_alignParentBottom="true"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp"/>
</LinearLayout>
</TabHost>