0
我以常規方式使用傳呼機視圖。在下面的代碼中,我得到錯誤:android.support.v4.app.FragmentManager cannot be applied to android.app.FragmentManager
。我檢查了這一切的解決方案,並實現它們,因爲它們可以看出(進口的似乎OK),仍然我有這樣的錯誤...Android ViewPager FragmentManager無法應用錯誤
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
public class MyActivity extends FragmentActivity {
private static int NUM_PAGES = 0; //The number of pages to show.
private static ViewPager mPager; //The pager widget
private static PagerAdapter mPagerAdapter; //The pager adapter
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
mPager = (ViewPager) findViewById(R.id.pager);
//Next line is error
mPagerAdapter = new ScreenSlidePagerAdapter(getFragmentManager());
mPager.setAdapter(mPagerAdapter);
}
/**
* A simple pager adapter
*/
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
public ScreenSlidePagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
return MyFragment.create(position);
}
@Override
public int getCount() {
return NUM_PAGES;
}
}
...
}
謝謝你的答案 – michael