01
02
03
04
05
06
07
08
09
10
|
<?xml version=
"1.0"
encoding=
"utf-8"
?>
<LinearLayout xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/LinearLayout01"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
>
<TextView android:text=
"tab1 with linear layout"
android:id=
"@+id/TextView01"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
>
</TextView>
</LinearLayout>
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
|
<?xml version=
"1.0"
encoding=
"utf-8"
?>
<FrameLayout xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/FrameLayout02"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
>
<LinearLayout android:id=
"@+id/LinearLayout02"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
>
<TextView android:text=
"tab2"
android:id=
"@+id/TextView01"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
>
</TextView>
</LinearLayout>
</FrameLayout>
|
01
02
03
|
LayoutInflater inflater_tab1 = LayoutInflater.from(
this
);
inflater_tab1.inflate(R.layout.tab1, mTabHost.getTabContentView());
inflater_tab1.inflate(R.layout.tab2, mTabHost.getTabContentView());
|
01
02
|
mTabHost.addTab(mTabHost.newTabSpec(
"tab_test1"
).setIndicator(
"TAB 11"
).setContent(R.id.LinearLayout01));
mTabHost.addTab(mTabHost.newTabSpec(
"tab_test1"
).setIndicator(
"TAB 11"
).setContent(R.id.FrameLayout02));
|
01
02
03
04
05
06
|
TabHost mTabHost = getTabHost();
LayoutInflater inflater_tab1 = LayoutInflater.from(
this
);
inflater_tab1.inflate(R.layout.tab1, mTabHost.getTabContentView());
inflater_tab1.inflate(R.layout.tab2, mTabHost.getTabContentView());
mTabHost.addTab(mTabHost.newTabSpec(
"tab_test1"
).setIndicator(
"TAB 11"
).setContent(R.id.LinearLayout01));
mTabHost.addTab(mTabHost.newTabSpec(
"tab_test1"
).setIndicator(
"TAB 11"
).setContent(R.id.FrameLayout02));
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
|
<?xml version=
"1.0"
encoding=
"utf-8"
?>
<TabHost xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+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"
/>
<FrameLayout
android:id=
"@android:id/tabcontent"
android:layout_width=
"fill_parent"
android:layout_height=
"fill_parent"
>
</FrameLayout>
</LinearLayout>
</TabHost>
|
01
02
03
04
05
|
LayoutInflater inflater_tab1 = LayoutInflater.from(
this
);
inflater_tab1.inflate(R.layout.tab1, mTabHost.getTabContentView());
inflater_tab1.inflate(R.layout.tab2, mTabHost.getTabContentView());
mTabHost.addTab(mTabHost.newTabSpec(
"tab_test1"
).setIndicator(
"TAB a"
).setContent(R.id.LinearLayout01));
mTabHost.addTab(mTabHost.newTabSpec(
"tab_test2"
).setIndicator(
"TAB b"
).setContent(R.id.FrameLayout02));
|
01
02
03
04
05
06
07
08
|
setContentView(R.layout.main);
TabHost mTabHost = (TabHost)findViewById(R.id.tabhost);
mTabHost.setup();
LayoutInflater inflater_tab1 = LayoutInflater.from(
this
);
inflater_tab1.inflate(R.layout.tab1, mTabHost.getTabContentView());
inflater_tab1.inflate(R.layout.tab2, mTabHost.getTabContentView());
mTabHost.addTab(mTabHost.newTabSpec(
"tab_test1"
).setIndicator(
"TAB a"
).setContent(R.id.LinearLayout01));
mTabHost.addTab(mTabHost.newTabSpec(
"tab_test2"
).setIndicator(
"TAB b"
).setContent(R.id.FrameLayout02));
|