0

を検出されない:AndroidのレイアウトXMLは、自動ポップアップウィンドウで検出されたが、メンバーのどれも、私はストレートのチュートリアルからレイアウトXMLファイルを持っている

レイアウト/ partnertrial_summary.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> 
</TabHost> 

で私のActivityクラス、私は次のコードを使用しようとするが、失敗した場合:

mTabHost = findViewById(R.layout.partnertrial_summary.tabhost); 

これは失敗します。しかし、それはR.layout.partnertrial_summaryのグリーン部分を検証しますが、partnertrial_summaryのメンバーを自動ポップアップしようとすると何も表示されません。

私はXMLが有効であると仮定します。なぜなら、それはAndroidからまっすぐに来たので、私は私の最後に間違っています。私のActivityTabActivityではありませんが、普通のものを使ってTabHostを追加して、適切なリスナーを実装しても問題ないと思いました。私の考えが間違っているなら、私を訂正してください。

+0

を使用して見つけることができませんか? –

答えて

1
mTabHost = findViewById(R.layout.partnertrial_summary.tabhost); 

置き換える

LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
View view = inflater.inflate(R.layout.partnertrial_summary,null); 
mTabHost = (TabHost)view.findViewById(R.id.tabhost); 
以下、上記のようなレイアウトを膨張させることができるが、それは働いていたかどうかwhehter findViewById()

+0

これを試しましたが、助けにならなかった...まだメンバーを検出しません。インフレータの有無にかかわらず、私は他のリソースのメンバーを見ることができましたが、何らかの理由でこれを見ることはできませんでした。 –

+0

一度きれいにしてプロジェクトをビルド –

+0

きれいな+ビルド、ダイスを試してみました。 –

関連する問題