转载请声明 http://www.niuzhi.cc/
报了这个错,找了很久才找到原因
03-09 10:01:16.342: E/AndroidRuntime(9850): java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams
03-09 10:01:16.342: E/AndroidRuntime(9850): at android.widget.ListView.setupChild(ListView.java:1827)
03-09 10:01:16.342: E/AndroidRuntime(9850): at android.widget.ListView.makeAndAddView(ListView.java:1796)
03-09 10:01:16.342: E/AndroidRuntime(9850): at android.widget.ListView.fillDown(ListView.java:670)
03-09 10:01:16.342: E/AndroidRuntime(9850): at android.widget.ListView.fillFromTop(ListView.java:727)
03-09 10:01:16.342: E/AndroidRuntime(9850): at android.widget.ListView.layoutChildren(ListView.java:1646)
03-09 10:01:16.342: E/AndroidRuntime(9850): at android.widget.AbsListView.onLayout(AbsListView.java:1260)
03-09 10:01:16.342: E/AndroidRuntime(9850): at android.view.View.layout(View.java:7277)
03-09 10:01:16.342: E/AndroidRuntime(9850): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
03-09 10:01:16.342: E/AndroidRuntime(9850): at android.view.View.layout(View.java:7277)
03-09 10:01:16.342: E/AndroidRuntime(9850): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
03-09 10:01:16.342: E/AndroidRuntime(9850): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
03-09 10:01:16.342: E/AndroidRuntime(9850): at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
03-09 10:01:16.342: E/AndroidRuntime(9850): at android.view.View.layout(View.java:7277)
03-09 10:01:16.342: E/AndroidRuntime(9850): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
03-09 10:01:16.342: E/AndroidRuntime(9850): at android.view.View.layout(View.java:7277)
03-09 10:01:16.342: E/AndroidRuntime(9850): at android.view.ViewRoot.performTraversals(ViewRoot.java:1203)
03-09 10:01:16.342: E/AndroidRuntime(9850): at android.view.ViewRoot.handleMessage(ViewRoot.java:1957)
03-09 10:01:16.342: E/AndroidRuntime(9850): at android.os.Handler.dispatchMessage(Handler.java:99)
03-09 10:01:16.342: E/AndroidRuntime(9850): at android.os.Looper.loop(Looper.java:143)
03-09 10:01:16.342: E/AndroidRuntime(9850): at android.app.ActivityThread.main(ActivityThread.java:4310)
03-09 10:01:16.342: E/AndroidRuntime(9850): at java.lang.reflect.Method.invokeNative(Native Method)
03-09 10:01:16.342: E/AndroidRuntime(9850): at java.lang.reflect.Method.invoke(Method.java:507)
03-09 10:01:16.342: E/AndroidRuntime(9850): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-09 10:01:16.342: E/AndroidRuntime(9850): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-09 10:01:16.342: E/AndroidRuntime(9850): at dalvik.system.NativeStart.main(Native Method)
原因是我在ListView里的放RelativeLayout,并且把RelativeLayout的LayoutParam设为 RelativeLayout.LayoutParam所以才会报错,改为:ListView.
LayoutParam就不会出问题了