Cannot convert from android.support.v4.app.Fragment to android.app.Fragment

后端 未结 8 1579
南笙
南笙 2020-12-10 00:41

I\'m doing my first Android app, and wanted to get straight into the ICS API. I have so far created an app using an ActionBar, with swipeable tabs using Viewpager and Fragme

8条回答
  •  青春惊慌失措
    2020-12-10 01:13

    Whats going on here?

    While the Android Support package gives you a backwards-compatible Fragment implementation, the ActionBar is not part of the Android Support package. Hence, ActionBar.TabListener is expecting native API Level 11 Fragment objects. Consider using ActionBarSherlock to have both an action bar and Android Support fragments.

    but then I'm left with another problem in my FragmentPagerAdapter

    The FragmentPagerAdapter in the Android Support package is a bit messy -- it wants API Level 11 Fragment objects, not Android Support Fragment objects. However, you can clone the source to FragmentPagerAdapter (source is in your SDK) and create your own implementation that uses the support.v4 flavor of Fragment and kin.

提交回复
热议问题