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

后端 未结 2 1066
无人共我
无人共我 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.

    0 讨论(0)
  • 2021-01-26 06:31

    If you are using com.google.android.gms.maps.SupportMapFragment your activity must extends android.support.v4.app.FragmentActivity instead of android.app.Activity

    0 讨论(0)
提交回复
热议问题