部分代码如下
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

解决方案 »

  1.   

    你是说没有上面的Title了吧,你设定的Theme就是没有Title的风格呀。难道不知道什么意思就设定上去用吗?
    你可以找找有关android style的介绍。
      

  2.   

    谢谢。我是要设置成Notitle的风格,开始没设置notitle的时候选项卡上方没出现空白。设置了以后就出现了。你看图片 我是说选项卡上的字在选项卡的下方。
      

  3.   

    上面那个课程名是一个textView。中间的课程信息是用的相对布局。
      

  4.   

    我tabhost三个子页都是这样的。子页的布局应该没有问题吧?