2

I posted earlier today about updating slides in my PagerAdapter and was directed here: Android ViewPager: Move any page to end programatically?

I have tried to rework my FragmentPagerAdapter extended class to model the one on that page and I'm running into an issue on my constructor. See the comment in the code below for the error I"m getting. I'm not sure why it would work on the page above, but not for me.

private class ScreenSlidePagerAdapter extends FragmentPagerAdapter {
    ContestEntriesModel entries;

    //this yields an error in eclipse that says "Implicit super constructor
    // FragmentPagerAdapter() is undefined. Must explicitly invoke 
    //another constructor   
    public ScreenSlidePagerAdapter(ContestEntriesModel Entries) {
        this.entries = Entries;
    }

    @Override
    public long getItemId(int position) {
        return entries.entries[position].ContestEntryId;

    }

    @Override
    public int getItemPosition(Object object) {
        android.support.v4.app.Fragment f = (android.support.v4.app.Fragment)object;
        for(int i = 0; i < getCount(); i++){

            android.support.v4.app.Fragment fragment = getItem(i);
            if(fragment.equals(f)){

                return i;
            }
        }
        return POSITION_NONE;
    }


    @Override
    public android.support.v4.app.Fragment getItem(int position) {

        long entryId = getItemId(position);
        //Log.d("EntryIds",Integer.toString(entryId));
        if(mItems.get(entryId) != null) {
            return mItems.get(entryId);
        }
        Fragment f = ScreenSlidePageFragment.create(position);
        mItems.put(entryId, f);
        return f;
    }

    @Override
    public int getCount() {
        return NUM_PAGES;
    }
}

I'm still very green with android/java so I'm not entirely sure what that means. I composed this new question because I didn't want to keep piggy backing on my previous question.

TIA

Edit: I also tried with an ArrayList<> to completely match that sample, and got the same error.

Community
  • 1
  • 1
Christopher Johnson
  • 2,629
  • 7
  • 39
  • 70

1 Answers1

3

Well I am not sure why the original code does not get your error actually, but you can try changing your code this way in order to fix the error and call the super constructor as the error suggests:

Replace your constructor with this one and it should work:

public ScreenSlidePagerAdapter(FragmentManager fm, ContestEntriesModel Entries) {
    super(fm);
    this.entries = Entries;
}
Yoann Hercouet
  • 17,894
  • 5
  • 58
  • 85