I am following the tutorial here: http://www.javacodegeeks.com/2013/04/android-tutorial-using-the-viewpager.html I get this error in the "Problems": The return type is incompatible with FragmentPagerAdapter.getItem(int) Here is MyPageAdapter.java:
package com.example.loginandregistration;
import java.util.List;
import android.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
public class MyPageAdapter extends FragmentPagerAdapter {
private List<Fragment> fragments;
public MyPageAdapter(FragmentManager fm, List<Fragment> fragments) {
super(fm);
this.fragments = fragments;
}
@Override
public Fragment getItem(int position) {
return this.fragments.get(position);
}
@Override
public int getCount() {
return this.fragments.size();
}
}
The error is on line 25:
public Fragment getItem(int position) {
When I open up for the quick fix it gives me the one option to "Change return type of 'getItem(...)' to 'Fragment' but if I do that it gives me an error on the next line and is a continuous loop of those errors going back and forth.
Any help on fixing this really quick is apperciated! Thanks in advance!
Change this line
import android.app.Fragment;
to this line
import android.support.v4.app.Fragment;
This error occurs because you are using FragmentPagerAdapter
from the support package, thus it can only returns Fragment
class from the support package.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments