0
我正在爲android編寫一個應用程序,需要選項卡,並且我的列表中的內容滾動到了我的選項卡上。我知道這一定很簡單,但我找不到它。Android:內容滾動選項卡
這裏是我的main.xml
<TabWidget android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="@android:id/tabs" />
<FrameLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@android:id/tabcontent">
</FrameLayout>
這裏是Java代碼
公共類再次擴展TabActivity { @覆蓋 公共無效的onCreate( Bundle savedInstanceState){ super.onCreate(s avedInstanceState); setContentView(R.layout.main);
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, Download.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("download")
.setIndicator("", res.getDrawable(R.drawable.ok))
.setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs
intent = new Intent().setClass(this, Settings.class);
spec = tabHost.newTabSpec("settings")
.setIndicator("", res.getDrawable(R.drawable.ok))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
}
}
任何幫助將不勝感激。
傑森
是否有什麼原因讓您對tabactivity調用setContentView?你一般不應該那樣做。這幾乎肯定是因爲你的framelayout設置爲fill_parent。你不需要一個tabactivity的視圖,它在內部都有。 – Falmarri 2010-11-26 04:53:38