BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / mobile-terminal-at / #4364同步于 2011/10/9
该镜像源已超过 30 天没有更新,可能在源站已被删除。
MobileTerminalAT机器人发帖

关于TabHost嵌套在LinearLayout中的问题

CrazyBuddy
2011/10/9镜像同步0 回复
想把一个TabHost的嵌套在一个Linerlayout中,并且可以通过Tab调用其他的activity 想着用代码实现布局,编译没错 运行时会报错 说是被终止了 看logcat中的错误说自己写的这句错了 super.setContentView(layout); 我的布局代码是下面的 还请帮忙 选择继承的是TabActivity public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.main); LinearLayout layout=new LinearLayout(this); super.setContentView(layout); layout.setOrientation(LinearLayout.VERTICAL); final Button bt=new Button(this); bt.setText(R.string.chart1); bt.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT)); final Button btt=new Button(this); btt.setText(R.string.chart2); btt.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT)); //TabHost tab=getTabHost(); TabHost tab=new TabHost(this); tab.addTab(tab.newTabSpec("tab1").setIndicator("绘图",getResources().getDrawable(R.drawable.icon)) .setContent(new Intent(main.this,Drawchart.class))); tab.addTab(tab.newTabSpec("tab2").setIndicator("饼图",getResources().getDrawable(R.drawable.icon)) .setContent(new Intent(main.this,WeightDialChart.class))); //bt=(Button)findViewById(R.id.bt); //btt=(Button)findViewById(R.id.btt); layout.addView(this.bt); layout.addView(this.btt); layout.addView(tab); bt.setOnClickListener(new listener()); btt.setOnClickListener(new listener1()); } 在写代码时 layout.addView(bt); layout.addView(btt); layout.addView(tab); 这些都是灰色的 加个this后就不是灰的了 tab的这个没有办法按上面的方法进行操作
订阅后,新回复会通过你的通知中心匿名送达。
0 条回复
暂无回复 · 你可以订阅本帖等待新回复。