0
나는 안드로이드를 처음 접했다. includes가 포함 된 탭 호스트를 갖고 싶지만 탭이 표시되지 않습니다. 이 입력란에는 텍스트 상자 및 버튼과 같은 간단한 입력 로직이 포함됩니다. 모든 코드는 db 항목 등을 저장하는 것과 같은 주요 활동 내에 있습니다.TabHost 및 포함
다음은 코드입니다.
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabHost"
android:layout_width="fill_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/line"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"></TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1">
<include android:id="@+id/layout1"
layout="@layout/layout_add_details"
android:layout_width="match_parent"
android:layout_height="match_parent"></include>
<include android:id="@+id/layout2"
layout="@layout/layout_add_number"
android:layout_width="match_parent"
android:layout_height="match_parent"></include>
</FrameLayout>
</LinearLayout>
</TabHost>
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
TabHost tab = (TabHost) findViewById(R.id.tabHost);
tab.setup();
TabHost.TabSpec spec1 = tab.newTabSpec("TAB 1");
spec1.setIndicator("TAB 1");
spec1.setContent(R.id.layout1);
tab.addTab(spec1);
TabHost.TabSpec spec2 = tab.newTabSpec("TAB 2");
spec2.setIndicator("TAB 2");
spec2.setContent(R.id.layout2);
tab.addTab(spec2);
}
미리 감사드립니다.