我在 android 上为滑块寻呼机输入这个示例
http://developer.android.com/training/animation/screen-slide.html
但我在这一行得到一个错误 mPagerAdapter = new ScreenSliderPagerAdapter(getFragmentManager());
错误消息:构造函数*未定义
有人可以解释为什么项目错误吗?
下面的代码
import java.util.Locale;
import android.app.*;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
public class SignOnActivity extends FragmentActivity {
private static final int NUM_PAGES = 1;
private ViewPager mPager;
private PagerAdapter mPagerAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_on);
mPager = (ViewPager)findViewById(R.id.pager);
mPagerAdapter = new ScreenSliderPagerAdapter(getFragmentManager());
mPager.setAdapter(mPagerAdapter);
}
@Override
public void onBackPressed() {
if (mPager.getCurrentItem() == 0) {
super.onBackPressed();
} else {
mPager.setCurrentItem(mPager.getCurrentItem()-1);
}
}
public class ScreenSliderPagerAdapter extends FragmentStatePagerAdapter {
public ScreenSliderPagerAdapter(android.support.v4.app.FragmentManager fm) {
super(fm);
}
@Override
public android.support.v4.app.Fragment getItem(int position) {
return new ScreenSliderPageFragment();
}
@Override
public int getCount() {
return NUM_PAGES;
}
}
}