2

I am also trying to implement this project and i am getting ^Title^ error.

I know this error has been re-posted. see here: Error: The constructor MainActivity.ScreenSlidePagerAdapter(FragmentManager) is undefined and here: Eclipse doesnt recognize android.support.v13.app.FragmentActivity although I have android-support-v13 library

but none of the answers solved my problem. Maybe there something wrong with the libraries or??

Here is my code.

package kn.screenslide;

import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.NavUtils;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.Menu;
import android.view.MenuItem;

public class ScreenSlideActivity extends FragmentActivity {
     //The number of pages (wizard steps) to show in this demo.
    private static final int NUM_PAGES = 5;

//The pager widget, which handles animation and allows swiping horizontally to access previous and next wizard steps.

    private ViewPager mPager;

     //The pager adapter, which provides the pages to the view pager widget.
    private PagerAdapter mPagerAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_screen_slide);

        // Instantiate a ViewPager and a PagerAdapter.
        mPager = (ViewPager) findViewById(R.id.pager);
        mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
        mPager.setAdapter(mPagerAdapter);
        mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
            @Override
            public void onPageSelected(int position) {
                // When changing pages, reset the action bar actions since they are dependent
                // on which page is currently active. An alternative approach is to have each
                // fragment expose actions itself (rather than the activity exposing actions),
                // but for simplicity, the activity provides the actions in this sample.
                invalidateOptionsMenu();
            }
        });
    }

        //A simple pager adapter that represents 5 {@link ScreenSlidePageFragment} objects, in sequence.

    private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
        public ScreenSlidePagerAdapter(android.support.v4.app.FragmentManager fm) {
            super(fm);
        }


        //This is where fragments are created
        @Override
        public android.support.v4.app.Fragment getItem(int position) {
            return ScreenSlidePageAdapter.create(position);
        }

        @Override
        public int getCount() {
            return NUM_PAGES;
        }
    }
}
Community
  • 1
  • 1
  • http://stackoverflow.com/questions/14111898/the-import-android-support-v13-app-fragmentactivity-cannot-be-resolved – BobTheBuilder Mar 07 '13 at 12:59
  • simply imported that project and workng fine what is your problem? – Tamilselvan Kalimuthu Mar 07 '13 at 13:06
  • well unfortunately i do not want to use the whole package. works fine for me but i am not interested @Tamilselvan. I am trying to modify the ScreenSlider app and only. Problem is in the last part i am getting this error: The method create(int) is undefined for the type ScreenSlideActivity.ScreenSlidePagerAdapter –  Mar 07 '13 at 15:31
  • @baraky thanx but no help there. I also changer v13 to v4 and ScreenSlidePageFragment to ScreenSlidePageAdapter. –  Mar 07 '13 at 15:33

1 Answers1

1

Issue is in ScreenSlidePageAdapter.getItem(). Adapter doesn't have create() method.

//This is where fragments are created
@Override
public android.support.v4.app.Fragment getItem(int position) {
    return ScreenSlidePageAdapter.create(position);
}

You must return a Fragment here, not adapter.

Sergey Glotov
  • 20,200
  • 11
  • 84
  • 98
  • am trying to set setcontentview but it is showing an error of setcontentview is undefined in fragment. Can u tell me how can i declare my xml file.. xml contains listview and i need to set that. – AndroidOptimist Oct 22 '13 at 10:37