0

DialogPrefence에 ExpandableListAdapter를 추가하려고합니다. 내가 ListView를DialogPreference의 ExpandableListAdapter

HiddenChannelsListAdapter adapter = new HiddenChannelsListAdapter(ctx, tree, subscribed_channelsList); 
ListView lv = (ListView) vw.findViewById(R.id.list); 
lv.setAdapter(adapter); 

나는 그것이 ExpandableListAdapter으로 어떻게해야 그것을 어떻게했는지

내 레이아웃은

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/channels_list" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:clickable="true" 
    android:orientation="horizontal" > 
    <LinearLayout 
     android:id="@+id/channelsProgress" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:gravity="center" 
     android:orientation="vertical" 
     android:visibility="gone" > 

     <ProgressBar 
      android:id="@+id/pbChannelsProgress" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:descendantFocusability="beforeDescendants" > 
     </ProgressBar> 
    </LinearLayout> 
    <ExpandableListView 
     android:id="@+id/list" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     > 
    </ExpandableListView> 

</LinearLayout> 

이다? , ExpandableListView에서

03-25 14:24:23.780: E/AndroidRuntime(22187): FATAL EXCEPTION: main 
03-25 14:24:23.780: E/AndroidRuntime(22187): java.lang.ClassCastException: com.example.tvrplayer.ExampleReallySimpleExpandableListAdapter cannot be cast to android.widget.ListAdapter 

답변

1

전화 setAdapter(ExpandableListAdapter)AbsListView에서하지 일반 setAdapter(ListAdapter)을 :

ExampleReallySimpleExpandableListAdapter adapter = new ExampleReallySimpleExpandableListAdapter(ctx, groupData, childData); 
AbsListView lv = (AbsListView) vw.findViewById(R.id.list); 
lv.setAdapter(adapter); 

이 발생합니다. 이다

변경

ExpandableListView lv = (ExpandableListView) vw.findViewById(R.id.list); 
+0

Shweet에

AbsListView lv = (AbsListView) vw.findViewById(R.id.list); 

! 그것은 작동 – Harry

+0

아시나요? 만약 그들이 기본적으로 확장 할 수 있습니다? – Harry

+0

@ 해리, 너 무슨 뜻이야? 기본적으로 확장하고자하는 그룹에'expandGroup()'을 호출 하시겠습니까? – laalto