Set ListView item height
How are you inflating the view?
If you are setting 'parent' parameter to null like below, then layout parameters are ignored.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
...
View v = inflater.inflate(R.layout.filtered_trip_row, null);
…
return v;
}
Passing 'parent' to inflate should work as you expect.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
...
View v = inflater.inflate(R.layout.filtered_trip_row, parent);
…
return v;
}
This explains it in detail: Why does LayoutInflater ignore the layout_width and layout_height layout parameters I've specified?
To avoid getting UnsupportedOperationException
, you can add false
as an input parameter to the inflator
. Example:
inflater.inflate(R.layout.filtered_trip_row, parent, false)
@Override
public View getView(int position, View convertView, ViewGroup parent) {
...
View v = inflater.inflate(R.layout.filtered_trip_row, parent,false);
…
return v;
}
just pass boolean value to the method so that it add the yourrowlayout to the listview and it will not give error futher like error java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView
and add yourLayout which u wants to populate through Adapter
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cdpb="http://schemas.android.com/apk/res/ale.android.brainfitness"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="55dp">
...
</LinearLayout>
it works for me and i think it may help you