1

私は拡張するクラス(ExpandableListDataClass)を持っていますBaseExpandableListAdapter

以下のようなものからExpandableListDataClassを呼び出しています。Activity

ExpandableListDataClass expandableListDataClass = new ExpandableListDataClass(this, categories);
categoryExpandableListView.setAdapter(expandableListDataClass);

カテゴリは文字列配列です。つまり、 ExpandableListDataClassのgroupCountはカテゴリに依存し。最悪なのは、GridViewでグループアイテムを展開するためにをExpandableListView。それらGridViewは、カテゴリに応じて表示するデータが異なります。

内部getChildView()で次のコードを使用すると、完全に機能します

if(getGroup(groupPosition).toString().equals("ebooks")){
    expandableListInsideGridView.setAdapter(eBooksImageAdapterForExpandableList);
}else if(getGroup(groupPosition).toString().equals("ebrochures")){
    expandableListInsideGridView.setAdapter(eBrochuresImageAdapterForExpandableList);
}

しかし、そこから削除したいのはeBooksImageAdapterForExpandableListeBrochuresImageAdapterForExpandableListです。今私がやっていることはArrayList、既存のカテゴリーに従って作成しているからです。しかし、categories / groupCountがいくつあるかわからない場合は、それができません。

解決策を教えてください

4

1 に答える 1

0

ついに私は解決策を見つけることができました:-)

逆に説明します。

私はgetChildView()次のコード行を与える必要があります

expandableListInsideGridView.setAdapter(new ImageAdapterForExpandableList(expandableListDataClassContext, eItemThumbCachePathArrayListContainer.get(groupPosition), eItemNamesArrayListContainer.get(groupPosition), eItemUrlArrayListContainer.get(groupPosition)));

getChildView()を拡張するExpandableListDataClassにありますBaseExpandableListAdapter

私がしなければならなかったことはArrayList、同じタイプの他のいくつかのArraListsを含むを宣言することです。コードで詳しく説明すると、eItemThumbCachePathArrayListContainerは、ArrayList渡したいString型のArrayListを含むものです。これは私が使用した単純なロジックであり、私にとってはうまくいきます。

于 2012-07-20T11:40:24.580 に答える