Reputation: 2710
I just started learning Android, and I am having hard time with fragments. In my project I created a HomeFragment class that extends Fragment:
public class HomeFragment extends Fragment{...}
I have also inner class called DummySectionFragment
public static class DummySectionFragment extends Fragment {...}
In a FragmentPagerAdapter's subclass public Fragment getItem(int position) method I would like to instantiate and return instance of HomeFragment class but AndroidStudio is complaining saying that the types are not compatible, it doesn't have problems with DummySectionFragment though. Why is it happening? Both classes extends Fragment but only one works fine?
I was trying to avoid of having all Fragment classes as inner classes of main activity... Is it even possible? thank you!
Upvotes: 0
Views: 42
Reputation: 6182
If you are using the support library make sure you are using the support fragment in both places.
Example import android.support.v4.app.Fragment;
Upvotes: 2