我在我的应用中使用过TabHost。它没有在每个选项卡上单击显示xml文件。仅显示白色屏幕。类和布局在下面发布。请帮忙
public class HelpScreen extends TabActivity {
TabHost host;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.inst_manual);
host = getTabHost();
TabSpec btnHelp = host.newTabSpec("Buttons Help");
btnHelp.setIndicator("Buttons Help",getResources().getDrawable(R.drawable.brushes_help));
Intent buttonsHelp = new Intent().setClass(this, ButtonsHelp.class);
btnHelp.setContent(buttonsHelp);
TabSpec drawHelp = host.newTabSpec("Drawing Help");
drawHelp.setIndicator("Drawing Help",getResources().getDrawable(R.drawable.brushes_help));
Intent drawingHelp = new Intent().setClass(this, DrawingHelp.class);
drawHelp.setContent(drawingHelp);
host.addTab(btnHelp);
host.addTab(drawHelp);
}
}
按钮帮助类是,
public class ButtonsHelp extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.buttons_help); //THIS XML IS NOT SHOWN ON TAB CLICK
}
}
帮助屏幕布局
<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:id="@+id/tabLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</FrameLayout>
</LinearLayout>
</TabHost>