我是一个初学者,正在用列表和图表做一些工作。我使用了与 achartengine 示例提供的代码相同的代码。我的启动器活动,它是从 TabActivity 派生的,它的创建方法如下,
setContentView(R.layout.tabstrip);
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
SalesBarChart myChart = new SalesBarChart();
intent = myChart.execute(this);
spec = tabHost.newTabSpec("BarChart").setIndicator("BarChart",
res.getDrawable(R.drawable.ic_tab_barchart))
.setContent(intent);
tabHost.addTab(spec);
AverageTemperatureChart myChart1 = new AverageTemperatureChart();
intent = myChart1.execute(this);
spec = tabHost.newTabSpec("albums").setIndicator("Albums",
res.getDrawable(R.drawable.ic_tab_linechart))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(1);
我的 xml 文件看起来像,
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<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"
android:padding="5dp" />
</LinearLayout>
我在点击按钮时在 startactivity(intent) 中触发的相同意图有效,但在选项卡中无效。请帮忙。提前致谢。