2014-01-14 13 views
5

私はExpandableListViewViewPagerを使用していますので、onPageSelected()でリストをクリアする必要があります。clear ExpandableListView

私はListViewのためにそれを行うための一つの方法はsetAdapter(null)である知っているが、私はExpandableListViewでそれをしようとした場合、私はThe method setAdapter(ListAdapter) is ambiguous for the type ExpandableListViewエラーを取得します。

答えて

6

空のアダプタを入力しようとしましたか?以下のような何か:

ExpandableListAdapter adapter = new ExpandableListAdapter(); //or what ever adapter you use/created 
listView.setAdapter(adapter); 

これは、あなたがNULLポインタを取得することはありませんし、アダプタが移入/ /ショーを表示するには、何の要素が含まれることはありませんではないヌルアダプタです。

adapterは、以下のようにBaseExpandableListAdapterと型鋳造ヌルで試してみてくださいisEmpty()

+0

働いて、ありがとうございました。 – hypd09

9

を呼び出して、空であるかどうかをチェックすることができます。

listview.setAdapter((BaseExpandableListAdapter)null); 
+0

ありがとうございました。 – oguzhan