我的应用程序中显示tabhost时出现问题。我试过任何类型的代码。我知道我必须调用tabwidget @android:id/tabs和其他类似的东西,但我仍然无法设法在我的应用程序中显示选项卡式视图。我需要4个标签,我不知道该怎么做。你可以帮帮我吗?????TabHost不显示
正如一些你想要的代码,那就是:
<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:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<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" >
<TextView
android:id="@+id/textview1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="this is a tab" />
<TextView
android:id="@+id/textview2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="this is another tab" />
<TextView
android:id="@+id/textview3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="this is a third tab" />
</FrameLayout>
</LinearLayout>
并在Java:
TabHost mTabHost = (TabHost)findViewById(android.R.id.tabhost);
mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("TAB 1").setContent(R.id.textview1));
mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("TAB 2").setContent(R.id.textview2));
mTabHost.addTab(mTabHost.newTabSpec("tab_test3").setIndicator("TAB 3").setContent(R.id.textview3));
mTabHost.setCurrentTab(0);
这是我从链接承担了代码第一个答案。
即使我们不知道该回答什么。请提供一些代码或提及您遇到的错误。 – xyz 2012-03-23 16:35:39
我没有任何代码,我只是用我在互联网上发现的东西尝试过 – Cippo 2012-03-23 16:38:00
到目前为止你得到了什么?你能显示一些代码吗? – goodm 2012-03-23 16:38:41