xml代码:<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >
    <TabHost android:id="@+id/tabhost"  
        android:layout_width="wrap_content"  
        android:layout_height="wrap_content">
        <LinearLayout  
           android:orientation="vertical"  
           android:layout_width="fill_parent"  
           android:layout_height="fill_parent">
          <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="wrap_content"  
               android:layout_height="wrap_content">
                  <!--进账页面-->
<LinearLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"> 
    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
         <TextView android:text="@string/date"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
         <EditText android:layout_width="120dp"
             android:layout_height="wrap_content"
             android:id="@+id/txtIncomeTime"
             android:inputType="number"
             />
         <Button android:id="@+id/btnSelectIncomeDate" 
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:text="@string/selectDate"/>
    </LinearLayout>
    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <TextView android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/count"/>
        <EditText android:id="@+id/txtIncomeCount"
            android:layout_width="150dp"
            android:layout_height="wrap_content"
            android:inputType="number"
            />
    </LinearLayout>
    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
         <TextView android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/incometype"/>
        <Spinner android:id="@+id/spinnerIncomeOrg"
            android:layout_width="150dp"
            android:layout_height="wrap_content"
            />
    </LinearLayout>
    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center_vertical">
         <TextView android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/type"/>
        <RadioGroup android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <RadioButton 
                android:id="@+id/rdbIncomeCash"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/cash"/>
            <RadioButton  
                android:id="@+id/rdbIncomeCard"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/card"/>
        </RadioGroup>
    </LinearLayout>
  <LinearLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center_vertical">
         <TextView android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/comment"/>
       <EditText android:layout_width="180dp"
           android:layout_height="wrap_content"
           android:inputType="text"/>
    </LinearLayout>
    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center"
        >
        <Button 
            android:id="@+id/btnIncomeOk"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/ok"/>
        <Button 
             android:id="@+id/btnIncomeCancel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/cancel"/>
    </LinearLayout>
</LinearLayout>
<!--支出页面-->
<LinearLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="支出"/>
</LinearLayout>
<!--统计页面-->
<LinearLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent">
     <TextView 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="统计"/>
</LinearLayout>
<!--设置页面-->
<LinearLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent">
     <TextView 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="设置"/>
</LinearLayout>
    </FrameLayout>
    </LinearLayout>
    </TabHost>
</RelativeLayout>
tabhost布局

解决方案 »

  1.   

    你检查一下是不是demin或者string没定义。其他没什么错误。
      

  2.   

    Exception raised during rendering: Could not create tab content because could not find view with id -1,大概说的是tab没有用对,可是我检查了好久没发现啊
      

  3.   

    最外层不需要relativelayout换成tabhost
      

  4.   

    布局错误eclipse会在当前行有提示的吧,找到后再仔细检查下附近的代码