java.lang.ClassCastException cannot be cast to android.app.Fragment

后端 未结 2 1071
无人共我
无人共我 2021-01-26 05:40

I have MainActivity class which have method which instantiate ApplicationBar, all other Activities are inherited form this MainActivity so they can use this method.

2条回答
  •  时光取名叫无心
    2021-01-26 06:14

    You are attempting to cast a SupportMapFragment to be a native API Level 11 android.app.Fragment. That will not work. Either:

    • Set your android:minSdkVersion to 11 or higher, and use MapFragment instead of SupportMapFragment, or

    • Cast your SupportMapFragment to be an android.support.v4.app.Fragment

    The issue is if I extend it from FragmentActivity I cannot display ApplicationBar Tabs

    The action bar was added to Android in API Level 11. If you wish to use an action bar on older versions of Android, you will need to use a backport, either ActionBarSherlock or the AppCompat backport in the Android Support package.

提交回复
热议问题