Set Height of ListView at run time in android
android, listview
Solution
Try This code..
LayoutParams lp = (LayoutParams) mListView.getLayoutParams();
lp.height = 300;
mListView.setLayoutParams(lp);
Problem
How to set Height of ListView. XML Code (This code is working fine and fixed height as 200 dip) ``` <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="5dip" android:orientation="vertical" > <ListView android:id="@+id/dialog_ListView" android:layout_width="wrap_content" android:layout_height="200dip" android:padding="5dip" android:layout_weight="1" android:dividerHeight="5dip" android:divider="@android:color/transparent" /> </LinearLayout> ``` Android Code (This code not fixed width and height) ``` convertView = mInflater.inflate( R.layout.dialog_page, null ); convertView.setLayoutParams( new ListView.LayoutParams( 200, 300) ); ``` Android Code (This code i got Error Message) ``` convertView = mInflater.inflate( R.layout.lock_file_page, parent ); convertView.setLayoutParams( new ListView.LayoutParams( 200, 300) ); ``` Error Message ``` java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView ``` How do fix Width and Height at Runtime. Thanks in advance.