3

コードでフラグメントを使用しようとしています..フラグメントをクリックして画面の向きを変更しようとすると、以下のようなエラーが発生しました...

Unable to start activity ComponentInfo{com.example.frag/com.example.frag.Activity}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment

私の Xml

<LinearLayout android:id="@+id/linear" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" >
<ListView android:id="@+id/android:list" android:layout_height="wrap_content" android:layout_width="fill_parent"/> 
<fragment android:id="@+id/frag" android:layout_height="fill_parent" android:layout_width="fill_parent" class="com.example.frag.MyFragment"/> 

4

3 に答える 3

2

私は答えを見つけました..FragmentActivityの代わりに拡張するのを忘れていましたActivity..

それは今働いています。

参照: https://stackoverflow.com/a/9168223/1542636

于 2013-04-29T05:00:47.180 に答える
1

あなたが提供している情報が限られているため、この投稿で対処されているのと同じ問題が発生しているようです。

于 2013-04-29T04:49:20.347 に答える
0

これを試して:

 <fragment
    android:id="@+id/frag"
    android:name="com.example.frag.MyFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:layout="@layout/frag_layout" />

android:name="完全修飾パス" を使用する必要があります。class="" を使用しました。

于 2013-04-29T05:12:00.600 に答える