09-24 12:56:16.471: E/AndroidRuntime(10696): at dalvik.system.NativeStart.main(Native Method)
错误原因:
Caused by: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
Context中有一个startActivity方法,Activity继承自Context,重载了startActivity方法。如果使用Activity的startActivity方法,不会有任何限制,而如果使用Context的startActivity方法的话,就需要开启一个新的task,遇到上面那个异常的,都是因为使用了Context的startActivity方法。解决办法是,加一个flag。
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
09-24 13:19:06.821: E/libEGL(12237): call to OpenGL ES API with no current context (logged once per thread)
09-24 13:19:06.850: E/AndroidRuntime(12237): FATAL EXCEPTION: main
09-24 13:19:06.850: E/AndroidRuntime(12237): Process: com.example.nongmin, PID: 12237
09-24 13:19:06.850: E/AndroidRuntime(12237): java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.RelativeLayout$LayoutParams
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.RelativeLayout$DependencyGraph.findRoots(RelativeLayout.java:1893)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.RelativeLayout$DependencyGraph.getSortedViews(RelativeLayout.java:1838)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.RelativeLayout.sortChildren(RelativeLayout.java:390)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:398)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.View.measure(View.java:17437)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.ListView.measureScrapChild(ListView.java:1503)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.ListView.measureHeightOfChildren(ListView.java:1571)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.ListView.onMeasure(ListView.java:1478)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.View.measure(View.java:17437)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5437)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1616)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.LinearLayout.measureVertical(LinearLayout.java:729)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.LinearLayout.onMeasure(LinearLayout.java:601)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.View.measure(View.java:17437)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5437)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1616)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1189)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.LinearLayout.onMeasure(LinearLayout.java:603)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.View.measure(View.java:17437)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1488)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.View.measure(View.java:17437)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5437)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1616)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.LinearLayout.measureVertical(LinearLayout.java:729)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.LinearLayout.onMeasure(LinearLayout.java:601)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.View.measure(View.java:17437)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5437)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.FrameLayout.onMeasure(FrameLayout.java:332)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.View.measure(View.java:17437)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5437)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1616)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.LinearLayout.measureVertical(LinearLayout.java:729)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.LinearLayout.onMeasure(LinearLayout.java:601)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.View.measure(View.java:17437)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5437)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.FrameLayout.onMeasure(FrameLayout.java:332)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.View.measure(View.java:17437)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5437)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1616)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.LinearLayout.measureVertical(LinearLayout.java:729)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.LinearLayout.onMeasure(LinearLayout.java:601)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.View.measure(View.java:17437)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5437)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.widget.FrameLayout.onMeasure(FrameLayout.java:332)
09-24 13:19:06.850: E/AndroidRuntime(12237): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2547)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.View.measure(View.java:17437)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2788)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1444)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1885)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1321)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6935)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:788)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.Choreographer.doCallbacks(Choreographer.java:591)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.Choreographer.doFrame(Choreographer.java:560)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:774)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.os.Handler.handleCallback(Handler.java:808)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.os.Handler.dispatchMessage(Handler.java:103)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.os.Looper.loop(Looper.java:193)
09-24 13:19:06.850: E/AndroidRuntime(12237): at android.app.Act
错误原因:我布局立面用的是relativeLayout布局,但是在我的adapter立面我重新给他设置大小的时候调用的确实linearLayout布局