Что не так с этим кодом для использования ViewPager?

Я пытаюсь получить очень базовую программу, которая использует ViewPager . Но я получаю java-ошибку, когда пытаюсь выполнить ее на своем телефоне. Вот код (я пытаюсь сделать модифицированную версию учебника)

 public class MainActivity extends ActionBarActivity { private ViewPager pager; private PagerAdapter pageAdapter; private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter { public ScreenSlidePagerAdapter(FragmentManager fm) { super(fm); } @Override public Fragment getItem(int position) { CardListFragment clf = new CardListFragment(); if (position == 0) clf.setThetext("Hola"); else if (position == 1) clf.setThetext("Mundo"); else if (position == 2) clf.setThetext("Cruel"); return clf; } @Override public int getCount() { return 3; } } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.activity_main); LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); ll.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); pager = new ViewPager(this); pager.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); pageAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager()); pager.setAdapter(pageAdapter); ll.addView(pager); setContentView(ll); } } 

И CardListFragment

 public class CardListFragment extends Fragment { public void setThetext(String thetext) { this.thetext = thetext; } private String thetext = "Antes"; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { TextView textView = new TextView(container.getContext()); textView.setTextSize(28); textView.setText(thetext); return textView; } } 

Ошибка, которую я получаю ( stack trace ):

 21385-21385/lengendary.app E/AndroidRuntime﹕ FATAL EXCEPTION: main android.content.res.Resources$NotFoundException: Unable to find resource ID #0xffffffff at android.content.res.Resources.getResourceName(Resources.java:1686) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:919) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104) at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467) at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:472) at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:163) at android.support.v4.view.ViewPager.populate(ViewPager.java:1068) at android.support.v4.view.ViewPager.populate(ViewPager.java:914) at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1436) at android.view.View.measure(View.java:15593) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) at android.widget.LinearLayout.measureVertical(LinearLayout.java:695) at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) at android.view.View.measure(View.java:15593) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825) at android.widget.FrameLayout.onMeasure(FrameLayout.java:314) at android.view.View.measure(View.java:15593) at android.widget.LinearLayout.measureVertical(LinearLayout.java:847) at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) at android.view.View.measure(View.java:15593) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825) at android.widget.FrameLayout.onMeasure(FrameLayout.java:314) at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2183) at android.view.View.measure(View.java:15593) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1878) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1089) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1265) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4356) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749) at android.view.Choreographer.doCallbacks(Choreographer.java:562) at android.view.Choreographer.doFrame(Choreographer.java:532) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735) at android.os.Handler.handleCallback(Handler.java:725) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:213) at android.app.ActivityThread.main(ActivityThread.java:5092) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:564) at dalvik.system.NativeStart.main(Native Method) 

Любые идеи о том, что я делаю неправильно?

Это довольно распространенная проблема с ViewPagers. Вам нужно установить идентификатор для вашего пейджера. В документации указано это вверху:

 When using FragmentPagerAdapter the host ViewPager must have a valid ID set. 

http://developer.android.com/reference/android/support/v4/app/FragmentStatePagerAdapter.html