私のXMLにListviewがあります。そのようなことの構造:Android 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"/>
は、今私は、JavaコードでListview
のための高さを設定します。私は次のコードで試しています。
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
です。私のコードの問題は何ですか?
LayoutParamsが機能します。しかし、castListItemView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT、500))は、レイアウトの上にあるものを上書きします。リストビューは画像の上にありますが、リストビューの内容は画像上に配置されます。これをどうすれば解決できますか? – Ashwin
@Ashwinあなたが何を意味するか分かりません。コードと別の質問を投稿できますか? – theisenp