分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow
也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!
10-20 16:30:48.160: E/AndroidRuntime(9031): java.lang.IllegalArgumentException: No view found for id 0x7f0a0075 (com.xxx.xxx:id/viewpager) for fragment OrderFragment{41dbca38 #2 id=0x7f0a0075 android:switcher:2131361909:0}10-20 16:30:48.160: E/AndroidRuntime(9031): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:919)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:472)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.support.v4.view.ViewPager.populate(ViewPager.java:1068)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.support.v4.view.ViewPager.populate(ViewPager.java:914)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1436)10-20 16:30:48.160: E/AndroidRuntime(9031): at xxxxxxxxxx.ViewPagerExt.onMeasure(ViewPagerExt.java:119)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.view.View.measure(View.java:16560)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5147)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1427)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.widget.LinearLayout.measureVertical(LinearLayout.java:713)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.widget.LinearLayout.onMeasure(LinearLayout.java:606)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.view.View.measure(View.java:16560)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5147)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.view.View.measure(View.java:16560)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.widget.LinearLayout.measureVertical(LinearLayout.java:865)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.widget.LinearLayout.onMeasure(LinearLayout.java:606)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.view.View.measure(View.java:16560)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5147)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)10-20 16:30:48.160: E/AndroidRuntime(9031): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2380)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.view.View.measure(View.java:16560)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1949)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1132)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1314)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1019)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5754)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.view.Choreographer.doCallbacks(Choreographer.java:574)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.view.Choreographer.doFrame(Choreographer.java:544)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.os.Handler.handleCallback(Handler.java:733)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.os.Handler.dispatchMessage(Handler.java:95)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.os.Looper.loop(Looper.java:136)10-20 16:30:48.160: E/AndroidRuntime(9031): at android.app.ActivityThread.main(ActivityThread.java:5297)10-20 16:30:48.160: E/AndroidRuntime(9031): at java.lang.reflect.Method.invokeNative(Native Method)10-20 16:30:48.160: E/AndroidRuntime(9031): at java.lang.reflect.Method.invoke(Method.java:515)10-20 16:30:48.160: E/AndroidRuntime(9031): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:851)10-20 16:30:48.160: E/AndroidRuntime(9031): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:667)10-20 16:30:48.160: E/AndroidRuntime(9031): at dalvik.system.NativeStart.main(Native Method)
今天想在一个Activity的子类里实现两个TAB左右滑动切换的效果。
于是想借助ViewPager和Fragment来搞
主要代码大概如下
mViewPager = (ViewPagerExt) findViewById(R.id.viewpager);//mViewPager是定义在当前Layout中的mViewPager.setAdapter(new FragmentPagerAdapter(FragmentManager, List<Fragment>));//传入的参数,第一个参数是 MainFragment.getInstance().getSupportFragmentManager()
报了如下异常,感觉很莫名其妙 No view found for id 0x7f0a0075 (com.xxx.xxx:id/viewpager) for fragment
查了半天,原来setAdapter的时候会在传入的第一个参数MainFragment所在的layout中查找该ID
于是不得不改变当前类的父类
OrderActivity extends FragmentActivity 而不是继承Activity
给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow
![这里写图片描述](https://i-blog.csdnimg.cn/blog_migrate/2e19ffb3303a490d20ea5d00dd397156.gif)