ViewPager手动创建中的问题
-12 23:29:41.202: E/AndroidRuntime(1850): FATAL EXCEPTION: main
03-12 23:29:41.202:
E/AndroidRuntime(1850): android.content.res.Resources$NotFoundException: Unable to find resource
ID #0xffffffff
03-12 23:29:41.202: E/AndroidRuntime(1850): at
android.content.res.Resources.getResourceName(Resources.java:1775)
03-12 23:29:41.202:
E/AndroidRuntime(1850): at android.support.v4.app.FragmentManagerImpl.moveToState
(FragmentManager.java:919)
03-12 23:29:41.202: E/AndroidRuntime(1850): at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
03-12
23:29:41.202: E/AndroidRuntime(1850): at android.support.v4.app.BackStackRecord.run
(BackStackRecord.java:682)
03-12 23:29:41.202: E/AndroidRuntime(1850): at
android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
03-12
23:29:41.202: E/AndroidRuntime(1850): at
android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:472)
03-12 23:29:41.202: E/AndroidRuntime(1850): at
android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
03-12
23:29:41.202: E/AndroidRuntime(1850): at android.support.v4.view.ViewPager.populate
(ViewPager.java:1068)
03-12 23:29:41.202: E/AndroidRuntime(1850): at
android.support.v4.view.ViewPager.populate(ViewPager.java:914)
03-12 23:29:41.202:
E/AndroidRuntime(1850): at android.support.v4.view.ViewPager.onMeasure
(ViewPager.java:1436)
03-12 23:29:41.202: E/AndroidRuntime(1850): at
android.view.View.measure(View.java:15848)
03-12 23:29:41.202: E/AndroidRuntime(1850): at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5012)
03-12 23:29:41.202:
E/AndroidRuntime(1850): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
03-
12 23:29:41.202: E/AndroidRuntime(1850): at android.view.View.measure(View.java:15848)
03-
12 23:29:41.202: E/AndroidRuntime(1850): at android.widget.LinearLayout.measureHorizontal
(LinearLayout.java:1034)
03-12 23:29:41.202: E/AndroidRuntime(1850): at
android.widget.LinearLayout.onMeasure(LinearLayout.java:590)
03-12 23:29:41.202: E/AndroidRuntime
(1850): at android.view.View.measure(View.java:15848)
03-12 23:29:41.202:
E/AndroidRuntime(1850): at android.view.ViewGroup.measureChildWithMargins
(ViewGroup.java:5012)
03-12 23:29:41.202: E/AndroidRuntime(1850): at
android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
03-12 23:29:41.202: E/AndroidRuntime
(1850): at android.view.View.measure(View.java:15848)
03-12 23:29:41.202:
E/AndroidRuntime(1850): at android.view.ViewGroup.measureChildWithMargins
(ViewGroup.java:5012)
03-12 23:29:41.202: E/AndroidRuntime(1850): at
com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:302)
03-
12 23:29:41.202: E/AndroidRuntime(1850): at android.view.View.measure(View.java:15848)
03-
12 23:29:41.202: E/AndroidRuntime(1850): at android.view.ViewGroup.measureChildWithMargins
(ViewGroup.java:5012)
03-12 23:29:41.202: E/AndroidRuntime(1850): at
android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
03-12 23:29:41.202: E/AndroidRuntime
(1850): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure
(PhoneWindow.java:2189)
03-12 23:29:41.202: E/AndroidRuntime(1850): at
android.view.View.measure(View.java:15848)
03-12 23:29:41.202: E/AndroidRuntime(1850): at
android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1905)
03-12 23:29:41.202:
E/AndroidRuntime(1850): at android.view.ViewRootImpl.measureHierarchy
(ViewRootImpl.java:1104)
03-12 23:29:41.202: E/AndroidRuntime(1850): at
android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1284)
03-12 23:29:41.202:
E/AndroidRuntime(1850): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1004)
03-12 23:29:41.202: E/AndroidRuntime(1850): at
android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5481)
03-12 23:29:41.202:
E/AndroidRuntime(1850): at android.view.Choreographer$CallbackRecord.run
(Choreographer.java:749)
03-12 23:29:41.202: E/AndroidRuntime(1850): at
android.view.Choreographer.doCallbacks(Choreographer.java:562)
03-12 23:29:41.202:
E/AndroidRuntime(1850): at android.view.Choreographer.doFrame(Choreographer.java:532)
03-
12 23:29:41.202: E/AndroidRuntime(1850): at
android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
03-12
23:29:41.202: E/AndroidRuntime(1850): at android.os.Handler.handleCallback(Handler.java:730)
03
-12 23:29:41.202: E/AndroidRuntime(1850): at android.os.Handler.dispatchMessage
(Handler.java:92)
03-12 23:29:41.202: E/AndroidRuntime(1850): at android.os.Looper.loop
(Looper.java:137)
03-12 23:29:41.202: E/AndroidRuntime(1850): at
android.app.ActivityThread.main(ActivityThread.java:5103)
03-12 23:29:41.202: E/AndroidRuntime
(1850): at java.lang.reflect.Method.invokeNative(Native Method)
03-12 23:29:41.202:
E/AndroidRuntime(1850): at java.lang.reflect.Method.invoke(Method.java:525)
03-12
23:29:41.202: E/AndroidRuntime(1850): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
03-12
23:29:41.202: E/AndroidRuntime(1850): at com.android.internal.os.ZygoteInit.main
(ZygoteInit.java:553)
03-12 23:29:41.202: E/AndroidRuntime(1850): at
dalvik.system.NativeStart.main(Native Method)
只需要对viewPager添加id值就可以,如viewPager.setId(任意值);