2017-02-23 9 views
1

にシンボルアンドロイドを解決することはできません私はアンドロイドの開発に新たなんだと私は私のxmlファイル作られたので、私は3つのタブでTabHostレイアウトに取り組んでいます:がTabHost方法

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

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

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

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

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

        <TableLayout 
         android:layout_width="match_parent" 
         android:layout_height="match_parent"> 

         <TableRow 
          android:layout_width="match_parent" 
          android:layout_height="match_parent"> 

          <TextView 
           android:text="Simple" 
           android:gravity="center" 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:id="@+id/textView24" 
           android:layout_weight="1"/> 

          <TextView 
           android:text="Continuous" 
           android:gravity="center" 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:id="@+id/textView23" 
           android:layout_weight="1"/> 

          <TextView 
           android:text="Perfect Simple" 
           android:gravity="center" 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:id="@+id/textView15" 
           android:layout_weight="1"/> 

          <TextView 
           android:text="Perfect Continuous" 
           android:gravity="center" 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:id="@+id/textView8" 
           android:layout_weight="1"/> 
         </TableRow> 

         <TableRow 
          android:layout_width="match_parent" 
          android:layout_height="match_parent" /> 

        </TableLayout> 
       </LinearLayout> 

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

        <TextView 
         android:text="NTM1" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:id="@+id/textView25" /> 
       </LinearLayout> 

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

        <TextView 
         android:text="NTM2" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:id="@+id/textView26" /> 
       </LinearLayout> 
      </FrameLayout> 
     </LinearLayout> 
    </TabHost> 
</LinearLayout> 

を、ここで心配で私のコードです

@Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.time); 

    } 
    TabHost tab =(TabHost) findViewById(R.id.ntm); 
    tab.setup(); 

    TabHost.TabSpec spec1 = tab.newTabSpec("PRESENT"); 
    spec1.setIndicator("PRESENT"); 
    spec1.setContent(R.id.Present); 
    tab.addTab(spec1); 

    TabHost.TabSpec spec2 = tab.newTabSpec("PAST"); 
    spec2.setIndicator("PAST"); 
    spec2.setContent(R.id.Past); 
    tab.addTab(spec2); 

    TabHost.TabSpec spec3 = tab.newTabSpec("FUTURE"); 
    spec3.setIndicator("FUTURE"); 
    spec3.setContent(R.id.Future); 
    tab.addTab(spec3); 

私はこのエラーを取得:EVで

cannot resolve symbol

をタブを初期化するための活動tab.setup()のようなeryメソッド、またはTabHostおよびTabSpecオブジェクトのすべてのメソッドがあります。

私はエラーを得なかっましmain activity、そこに私のコードをコピー/ペーストしようとしましたが、アプリケーションが瞬時に

答えて

0

をクラッシュ私は私のミスを見つけた、私はに初期化コードを入れていませんでした方法onCreateもうエラーはありません