0
tabhost의 동작은 기본적으로 자동으로 첫 번째 탭을 선택하고 그 내용을 표시합니다. 문제는 기본 페이지를 설정하고 싶습니다. 즉, 기본적으로 탭 호스트가 선택되지 않고 일부 홈 페이지 콘텐츠 (탭 호스트의 콘텐츠가 아닌)가 표시됩니다. 어떻게 그러한 기능을 구현합니까? 감사.android에서 탭 호스트의 기본 페이지를 설정하는 방법은 무엇입니까?
주요 활동
public class LandingPage extends FragmentActivity {
public FragmentTabHost tabHost;
public Resources res;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.landing_page);
res = getResources();
tabHost = (FragmentTabHost) findViewById(R.id.tabhost);
tabHost.setup(this, getSupportFragmentManager(), R.id.tabcontent);
tabHost.addTab(tabHost.newTabSpec("About").setIndicator("",res.getDrawable(R.drawable.btn_about)),About.class, null);
tabHost.addTab(tabHost.newTabSpec("Selfie").setIndicator("",res.getDrawable(R.drawable.btn_selfie)),About.class, null);
tabHost.addTab(tabHost.newTabSpec("Gallery").setIndicator("",res.getDrawable(R.drawable.btn_gallery)),About.class, null);
tabHost.addTab(tabHost.newTabSpec("LeaderBoard").setIndicator("",res.getDrawable(R.drawable.btn_board)),About.class, null);
tabHost.addTab(tabHost.newTabSpec("Events").setIndicator("",res.getDrawable(R.drawable.btn_events)),Events.class, null);
}
}
XML은
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<android.support.v4.app.FragmentTabHost
android:id="@+id/tabhost"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal"
android:background="@drawable/share_navigation_bar_bg" />
<FrameLayout
android:id="@+id/tabcontent"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>