部分代码如下
Activity中代码:protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
super.setContentView(R.layout.main_tabs);
this.myTabHost = this.getTabHost();
Intent intent = this.getIntent();
Bundle bundle = intent.getExtras();
String title = bundle.getString("courseName");
TextView tvTitle = (TextView)findViewById(R.id.title_tab);
tvTitle.setText(title);
//this.myTabHost = (TabHost) super.findViewById(R.id.tabhost);
//this.myTabHost.setup(); //建立TabHost对象
intent = new Intent(TabClassActivity.this,CourseInfoActivity.class);
intent.putExtras(bundle);
TabSpec myTab1 = this.myTabHost.newTabSpec("courseInfo")
.setIndicator(getResources().getString(this.strRes[0]))
.setContent(intent);
myTabHost.addTab(myTab1);
intent = new Intent(TabClassActivity.this,RelativeCoursesActivity.class);
intent.putExtras(bundle);
TabSpec myTab2 = this.myTabHost.newTabSpec("relativeCourses")
.setIndicator(getResources().getString(this.strRes[1]))
.setContent(intent);
myTabHost.addTab(myTab2);
intent = new Intent(TabClassActivity.this,RelativeBooksActivity.class);
intent.putExtras(bundle);
TabSpec myTab3 = this.myTabHost.newTabSpec("relativeBooks")
.setIndicator(getResources().getString(this.strRes[2]))
.setContent(intent);
myTabHost.addTab(myTab3);
}XML布局文件中代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/title_tab"
android:layout_width="match_parent"
android:layout_height="50sp"
android:background="@color/dark_gray"
android:textSize="25sp"
android:gravity="center"
android:textColor="@color/white"/>
<TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"><FrameLayout
android:id="@android:id/tabcontent"
android:paddingBottom="60sp"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<RadioGroup
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical" >
<RadioButton
android:id="@+id/radio_bn0"
android:text="@string/courseInfo"/>
<RadioButton
android:id="@+id/radio_bn1"
android:text="@string/relativeCourses"/>
<RadioButton
android:id="@+id/radio_bn2"
android:text="@string/relativeBooks"/>
</RadioGroup>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
</TabHost>
</LinearLayout>
开始好好的。好像是我在清单文件中设置了android:theme="@android:style/Theme.Light.NoTitleBar"就成这样了,为什么?
大神们求救啊。小弟初学Android。灰常感谢啦! AndroidtabhostRadioButtontextview
解决方案 »
- 菜鸟新人求解释handler.post
- listView的适配器Adapter不响应
- android添加希伯来语 ,荷兰语
- 请教一个关于GPS实时获取的问题!!
- android 事物操作
- 怎么在android的canvas上实现简单的涂鸦功能(paint可以有两种以上的颜色选择)
- 高分 请熟悉getContentResolver的朋友帮我看一段异常代码!!
- LogCat不显示的问题。
- 安装anroid sdk时出现Failed to fetch URL https://dl-ssl.google.com/android/repository/
- 得到一个Bitmap类型的数据mbitmap。。如何把它做成叫picture.png图片
- android socket构建TCP客户端实现自由收发!
- android:如何计算不同时区的时间差
你可以找找有关android style的介绍。