2016-09-02 13 views
1

私は断片を含む活性を持っています。なぜクラスフラグメントを膨張させるエラーが発生していますか?

活動はルックス:

activity_main.xml:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 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" 
    android:orientation="vertical" 
    tools:context="keepInTouch.mainScreen.MainActivity"> 



    <TextView 
     android:id="@+id/textV" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Hello World!" /> 

    <fragment 
     android:id="@+id/fragmnet_main_list" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     tools:layout="@layout/fragment_main_list" /> 
</LinearLayout> 


public class MainActivity extends AppCompatActivity { 

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

フラグメントルック: fragment_main_list.xml私は次のエラーを取得しています

<LinearLayout 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:orientation="vertical" 
    tools:context="keepInTouch.today.MainListFragment"> 


    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:text="@string/mainFragmentListTitle" 
     android:background="#e43d3d" 
     android:textColor="#371b1b" /> 


    <ListView 
     android:id="@+id/lvKits" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

</LinearLayout> 


public class MainListFragment extends Fragment { 

    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
     return inflater.inflate(R.layout.fragment_main_list, container, false); 
    } 

: android.viewを.InflateException:バイナリXMLファイル行#41:クラスを拡張するエラー。フラグメント

MainActivityが

FragmentActivity

を拡張しかし、私は同じ結果を得た:と私は MainActivityを交換しようとしている210

はAppCompatActivity を拡張します。

私は間違っていますか?

+0

あなたは名前属性を指定しませんでした –

答えて

1

にはという属性がありません。これを行う:

<fragment 
     android:id="@+id/fragmnet_main_list" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:name="keepInTouch.today.MainListFragment" 
     tools:layout="@layout/fragment_main_list" /> 
関連する問題