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