このプロジェクトも実装しようとしていますが、^Title^エラーが発生します。
このエラーが再投稿されたことを知っています。ここを参照してください:エラー:コンストラクターMainActivity.ScreenSlidePagerAdapter(FragmentManager)が未定義であり、ここを参照してください: android-support-v13ライブラリがありますが、Eclipseはandroid.support.v13.app.FragmentActivityを認識しません
しかし、どの答えも私の問題を解決しませんでした。たぶん、ライブラリに何か問題がありますか?
これが私のコードです。
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;
}
}
}