LinearLayout layout = (linearlayout) minflater.inflate ( null); New Linearlayout.layoutparams ( updeviceinfo.getdevicewidth (), layoutparams.wrap_content); Rootlayout.addview (Convertview, param);
I want to manually set the width of the layout, the result is an error (although a small chance to error)
Java.lang.classcastexception:android.view.viewgroup$layoutparams cannot is cast to android.widget.abslistview$ Layoutparams
WORKAROUND: Instead of creating a new layoutparams, get layoutparams from the original view
Linearlayout.layoutparams param = (android.widget.LinearLayout.LayoutParams) checklayout . Getlayoutparams ( ); = Updeviceinfo.getdevicewidth ();
It seems that when a view has layoutparams, it is best not to add a new layoutparams.
Android.view.viewgroup$layoutparams cannot is cast to Android.widget.abslistview$layoutparams