我正在尝试在 TabActivity 中显示 ListActivity,但由于某种原因,ListActivity 根本不会出现。我得到的只是标签下方的空白区域。
标签活动: https : //picasaweb.google.com/FlyingYellow/Misc#5629459368100202146 列表活动:https ://picasaweb.google.com/FlyingYellow/Misc#5629459406832281026
我完全不知道为什么会这样。我四处搜索,只找到有关输入问题的帖子。我什至无法显示我的内容!
TabActivity.onCreate()
super.onCreate(savedInstanceState);
setContentView(R.layout.browser);
Resources res = getResources();
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
intent = new Intent(this, ArtistBrowser.class);
spec = tabHost.newTabSpec("artists").setIndicator("Artists", res.getDrawable(R.drawable.ic_tab_artists));
spec.setContent(intent);
tabHost.addTab(spec);
intent = new Intent(this, AlbumBrowser.class);
spec = tabHost.newTabSpec("albums").setIndicator("Albums", res.getDrawable(R.drawable.ic_tab_artists));
spec.setContent(intent);
tabHost.addTab(spec);
intent = new Intent(this, TrackBrowser.class);
spec = tabHost.newTabSpec("tracks").setIndicator("Tracks", res.getDrawable(R.drawable.ic_tab_artists));
spec.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
(我遵循了 Android 文档教程)
/res/layout/browser.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="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="match_parent" /> <--- this was the error
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp" />
</LinearLayout>
</TabHost>