Should i declare the MainFragmentDemoActivity in manifest?

后端 未结 3 482
别那么骄傲
别那么骄傲 2021-01-28 10:34

I am trying to learn fragment.I am clicking a fragment class and my app crashes.I have declared it in the manifest..But why it is happening..My Menu class

public         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-28 11:03

    Your ListFragmentDemo extends from android.support.v4.app.Fragment (the support version of the Fragment class) and not android.app.Fragment (the version which is inside Android)

    Change

    import android.support.v4.app.Fragment;
    

    to

    import android.app.Fragment;
    

    in the ListFragmentDemo class

提交回复
热议问题