1

タブホストを含​​むアクティビティを起動しようとすると、次のエラーが発生します。

08-25 16:51:42.551: エラー/AndroidRuntime(27863): java.lang.RuntimeException: アクティビティ ComponentInfo{com.paratransit/com.paratransit.jobDialog} を開始できません: java.lang.RuntimeException: タブ コンテンツを作成できませんでしたID 2131165185 のビューが見つからなかったため

これは私のコードです。誰でも助けることができますか?

ジャワ

public Class jobDialog extends TabActivity {

    TabHost tabs;
 int jobCurrentTab = -1;

 @Override
 public void onCreate(Bundle savedInstanceState)
 {  
     super.onCreate(savedInstanceState);

        Bundle extras = getIntent().getExtras();
        setContentView(R.layout.job_dialog);

     tabs = getTabHost();
        tabs.setup();
     setupTabs();
 }

 public void setupTabs()
 {     
      TabSpec tspec1 = tabs.newTabSpec("First Tab");
      tspec1.setIndicator("Summary", getResources().getDrawable(R.drawable.tab_main)).setContent(R.id.jobDetail1);   
      tabs.addTab(tspec1);
      TabSpec tspec2 = tabs.newTabSpec("Second Tab");
      tspec2.setIndicator("Details", getResources().getDrawable(R.drawable.tab_message)).setContent(R.id.jobDetail2);
      tabs.addTab(tspec2);
      TabSpec tspec3 = tabs.newTabSpec("Third Tab");
      tspec3.setIndicator("Notes", getResources().getDrawable(R.drawable.tab_jobs)).setContent(R.id.jobDetail3);
      tabs.addTab(tspec3);

XML

<?xml version="1.0" encoding="utf-8"?>


<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp">

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp" />

       <LinearLayout
   android:id="@+id/jobDetail1"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" >   

  </LinearLayout>  

       <LinearLayout
   android:id="@+id/jobDetail2"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" >   

  </LinearLayout>  

  <LinearLayout
   android:id="@+id/jobDetail3"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" >   

  </LinearLayout>

    </LinearLayout>
</TabHost>
4

2 に答える 2

1

3 つの線形レイアウト、jobDetail1->3 は FrameLayout xml 要素内にある必要があると思います。FrameLayout のポイントは、すべてのビューが互いに重なり合っているため、タブ マネージャーが表示するビューを決定できることです。

于 2010-08-25T21:24:04.403 に答える
1

LinearLayout 内に LinearLayout を含めていないため、このエラーが発生していると思います。また、LinearLayout 内にいくつかの要素ビューを配置する必要があると思います。

このようなもの

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:id="@+id/establecimientoView">

<TabHost 
    android:id="@android:id/tabhost"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >


    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

         <TabWidget android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@android:id/tabs" />

         <FrameLayout android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@android:id/tabcontent" >


            <LinearLayout
                android:id="@+id/tabIdEst"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" >

                 <include layout="@layout/identificacion_establecimiento"/>

            </LinearLayout>


            <LinearLayout
                android:id="@+id/tabRefGeo"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" >

                 <include layout="@layout/referencia_geografica"/>
            </LinearLayout>

            <LinearLayout
                android:id="@+id/tabUbicEstablecimiento"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" >

                 <include layout="@layout/ubicacion_establecimiento"/>
            </LinearLayout>

                <LinearLayout
                android:id="@+id/tabVialidades"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" >

                 <include layout="@layout/entre_vialidades"/>
            </LinearLayout>

         </FrameLayout>
    </LinearLayout>

</TabHost>
</LinearLayout>
于 2012-08-02T16:24:46.487 に答える