I\'m just trying to have a look on Fragment and I got some probs with stupid stuff... There is my SkippersActivity.java :
public class SkippersActivity extends A
Another pitfall to watch out for is to make sure you don't forget to call super.onCreate() from your activity. If you make this dumb mistake like I did, you'll also see the "Error inflating class fragment" and "... cannot be cast to android.app.Fragment" errors, even if you haven't mismatched the standard and support.v4 versions of the classes.
If I had to guess, SkippersFragment
is extending android.support.v4.app.Fragment
. However, SkippersActivity
is not extending android.support.v4.app.FragmentActivity
. So SkippersActivity
is trying to use native API Level 11 fragments.
I ran into the same error while trying to extend ListFragment. My finding is that, to use ListFragment on a project with minSdkVersion < 11, I will have to import android.support.v4.app.ListFragment;
. Otherwise, I will have to import android.app.ListFragment;
.
This link clarified my question.
If you use the v4 compatibility package, your Activity has to extend FragmentActivity, not Activity. If you use Android > 3.0, then your Activity extends Activity, but read CommonsWare's answer about not mixing both types of fragments.