У меня есть ListView с пользовательским представлением, отображаемым адаптером. Он содержит изображение, некоторый текст и другой ListView. В методе getView адаптера я создал другой адаптер для настройки встроенного ListView.
Все это прекрасно работает, но по какой-то причине высоты встроенного ListView достаточно только для просмотра одного элемента списка. Если я вручную установлю высоту в пикселях, я смогу увидеть больше элементов в списке. Все высоты установлены на wrap_content, поэтому я не уверен, почему он не работает.
Мой первый ListView выглядит так:
<ListView
android:id="@+id/newswire"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:cacheColorHint="#ffffff"
/>
Элемент, который отображается для этого ListView:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
>
<ImageView
android:id="@+id/aggSparkAvatar"
android:layout_width="45dp"
android:layout_height="45dp"
android:scaleType="centerCrop"
/>
<LinearLayout
android:orientation="vertical"
android:paddingLeft="10dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/aggSparkName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#1B5F7C"
android:textStyle="bold"
/>
<TextView
android:id="@+id/aggSparkDateStamp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textStyle="bold"
/>
<View
android:layout_height="1dp"
android:layout_width="fill_parent"
android:background="#F2F2F2"
/>
<ListView
android:id="@+id/aggSparkList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:cacheColorHint="#ffffff"
/>
</LinearLayout>
</LinearLayout>
Тогда для встроенного ListView каждый элемент выглядит следующим образом:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
>
<ImageView
android:id="@+id/sparkAvatar"
android:layout_width="45dp"
android:layout_height="45dp"
android:scaleType="centerCrop"
/>
<LinearLayout
android:orientation="vertical"
android:paddingLeft="10dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/sparkTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textStyle="bold"
/>
<TextView
android:id="@+id/sparkText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
/>
<TextView
android:id="@+id/sparkDateStamp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#A2A2A2"
/>
</LinearLayout>
</LinearLayout>