04-02 16:55:31.153: E/AndroidRuntime(4874): Uncaught handler: thread main exiting due to uncaught exception 04-02 16:55:31.163: E/Monkey(4874): exception :java.io.FileNotFoundException: /dev/kmsg (Permission denied) 04-02 16:55:31.243: E/AndroidRuntime(4874): exception :java.io.FileNotFoundException: /dev/kmsg (Permission denied) 04-02 16:55:31.243: E/AndroidRuntime(4874): FATAL EXCEPTION: main 04-02 16:55:31.243: E/AndroidRuntime(4874): java.lang.ClassCastException: android.widget.AbsListView$LayoutParams 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.widget.RelativeLayout$DependencyGraph.findRoots(RelativeLayout.java:1303) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.widget.RelativeLayout$DependencyGraph.getSortedViews(RelativeLayout.java:1250) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.widget.RelativeLayout.sortChildren(RelativeLayout.java:281) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:303) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.view.View.measure(View.java:8342) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.widget.ListView.setupChild(ListView.java:1821) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.widget.ListView.makeAndAddView(ListView.java:1748) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.widget.ListView.fillDown(ListView.java:670) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.widget.ListView.fillFromTop(ListView.java:727) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.widget.ListView.layoutChildren(ListView.java:1598) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.widget.AbsListView.onLayout(AbsListView.java:1260) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.view.View.layout(View.java:7204) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:912) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.view.View.layout(View.java:7204) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1520) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.view.View.layout(View.java:7204) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.widget.LinearLayout.onLayout(LinearLayout.java:1047) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.view.View.layout(View.java:7204) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.view.View.layout(View.java:7204) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.widget.FrameLayout.onLayout(FrameLayout.java:338) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.view.View.layout(View.java:7204) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.view.ViewRoot.performTraversals(ViewRoot.java:1142) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.view.ViewRoot.handleMessage(ViewRoot.java:1876) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.os.Handler.dispatchMessage(Handler.java:99) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.os.Looper.loop(Looper.java:130) 04-02 16:55:31.243: E/AndroidRuntime(4874): at android.app.ActivityThread.main(ActivityThread.java:3683) 04-02 16:55:31.243: E/AndroidRuntime(4874): at java.lang.reflect.Method.invokeNative(Native Method) 04-02 16:55:31.243: E/AndroidRuntime(4874): at java.lang.reflect.Method.invoke(Method.java:507) 04-02 16:55:31.243: E/AndroidRuntime(4874): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:895) 04-02 16:55:31.243: E/AndroidRuntime(4874): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:653) 04-02 16:55:31.243: E/AndroidRuntime(4874): at dalvik.system.NativeStart.main(Native Method) 04-02 16:55:31.253: E/AndroidRuntime(4874): exception :java.io.FileNotFoundException: /dev/kmsg (Permission denied)
java.lang.ClassCastException: android.widget.AbsListView$LayoutParams
意思类型转换错误
subPager.setLayoutParams(new ListView.LayoutParams(ListView.LayoutParams.FILL_PARENT, 200)); // 这里的高绝对不能是WRAP_CONTENT
原因我设置了LayoutParams
就这一句代码搞了大半天
我的父节点用的是RelativeLayout
所以改为以下代码
subPager.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT,200));