すべてのグループに 1 つの子がある ExpandableListView があります。すべての子は、行数が異なる別の ListView です。展開された状態の ExpandableListView アイテムの高さに問題があり、子の ListView コンテンツにラップされません。子リストビュー レイアウトで具体的な高さの値を設定できます。しかし、すべての子を自動的にラップする ExpandableListView を取得したいと考えています。出来ますか?
getChildView(
) からExpandableListAdapter
:
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
if( convertView == null ) {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE );
convertView = inflater.inflate( R.layout.anit_object_data, parent, false );
}
ListView lv = (ListView)convertView.findViewById( R.id.listData );
List<ListData> valuesList = getItems().get(groupPosition).getListData( getContext() );
ListDataAdapter adapter = new ListDataAdapter( getContext(), android.R.layout.simple_list_item_1, valuesList );
lv.setAdapter(adapter);
return convertView;
}
子 ListView の XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id = "@+id/listHolder"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="40dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:orientation="horizontal" >
<ListView
android:id="@+id/listData"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:scrollbars="none" >
</ListView>
</LinearLayout>
</LinearLayout>
アダプターの getChildView() で子 ListView の高さを測定しようとしましたが、 ExpandableListView の展開されたアイテムの高さはまだ正しくありません。
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
if( convertView == null ) {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE );
convertView = inflater.inflate( R.layout.anit_object_data, parent, false );
}
ListView lv = (ListView)convertView.findViewById( R.id.listData );
List<ListData> valuesList = getItems().get(groupPosition).getListData( getContext() );
ListDataAdapter adapter = new ListDataAdapter( getContext(), android.R.layout.simple_list_item_1, valuesList );
lv.setAdapter(adapter);
lv.measure( MeasureSpec.EXACTLY, MeasureSpec.UNSPECIFIED );
convertView.getLayoutParams().height = lv.getMeasuredHeight();
return convertView;
}