我在我的应用中使用过TabHost。我按照教程来实现它。它运行良好但在单击选项卡时未显示指定的布局。这是代码。请帮忙
public class HelpScreen extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.inst_manual);
TabHost host = getTabHost();
TabSpec btnHelp = host.newTabSpec("Buttons Help");
btnHelp.setIndicator("Buttons Help",getResources().getDrawable(R.drawable.brushes_help));
Intent buttonsHelp = new Intent(HelpScreen.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(HelpScreen.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);
} }
答案 0 :(得分:0)
尝试创建这样的意图......
Intent buttonsHelp = new Intent().setClass(this, ButtonsHelp.class);
Intent drawingHelp = new Intent().setClass(this, DrawingHelp.class);