我的 xml 中有一个 Listview。它的结构是这样的:
<ListView
android:id="@+id/SeriesCastListItemView"
android:paddingTop="10dip"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="#FFFFFF"
android:dividerHeight="1px"/>
现在我想为Listview
by java 代码设置一个高度。我尝试使用以下代码。
ListView castListItemView = (ListView) findViewById(R.id.SeriesCastListItemView);
castListItemView.setAdapter(new CastAdapter(this, castDescriptionArr));
castListItemView.setLayoutParams(new ListView.LayoutParams(LayoutParams.FILL_PARENT, 500));
但它给予java.lang.ClassCastException: android.widget.AbsListView$LayoutParams
。我的代码有什么问题?