多语言展示
当前在线:1080今日阅读:57今日分享:41

Android:LayoutParameter不匹配问题

不同Layout,对应不同Layoutparameter,那么被嵌套的布局或者view,要尊用父布局的Layoutparameter类。
方法/步骤
1

不同Layout,对应不同Layoutparameter,那么被嵌套的布局或者view,要尊用父布局的Layoutparameter类。因为你的这个LinearLayout是放在一个ListView中(ListView是AbsListView的子类),所以LinearLayout.setLayoutParameters()中应该放AbsListView.LayoutParameter这个类的对象。

2

相关Bug:1)java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.RelativeLayout$LayoutParams:这段话提示我们不能将Linear$LayoutParams强制转换成RelativeLayout$LayoutParams

3

2):java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams在DDMS里面也没有具体定位哪里错了,逐步调试在return那里出错了,求解?分享到: 更多------解决方案--------------------  LinearLayout.LayoutParams _llp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.MATCH_PARENT);这句代码导致的错误哦------解决方案--------------------因为你的这个LinearLayout是放在一个ListView中(ListView是AbsListView的子类),所以LinearLayout.setLayoutParameters()中应该放AbsListView.LayoutParameter这个类的对象。

推荐信息