我不明白为什么我的可扩展列表视图的 onChildClick 方法出现致命异常

I dont understand why I am getting a fatal exception in my onChildClick method for my expandable list view

我有一个可扩展的列表视图,但是当我展开它并单击子项时,我收到一条错误消息

FATAL EXCEPTION: main Process: com.claritech.simsentinelmobile, PID: 22606 java.lang.ClassCastException: android.widget.ExpandableListConnector cannot be cast to com.xera.deviceinsight.home.ExpandableListAdapter

这是抛出错误的行

 ExpandableListAdapter adapter = (ExpandableListAdapter)parent.getAdapter();

这就是我尝试使用适配器检索对象的整个方法(有关使用改造从服务器中单击的子对象的详细信息)

 private void load(View view)
   {

      expListView = (ExpandableListView) view.findViewById(R.id.lvExp);
      prepareListData();
      listAdapter = new ExpandableListAdapter(this.getActivity(), listDataHeader, listDataChild);
      expListView.setAdapter(listAdapter);
      expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
         @Override
         public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {

            System.err.println("child clicked");
            Toast.makeText(getActivity(), "child clicked", Toast.LENGTH_SHORT).show();
            EventBus.getDefault().post(new ItemClickedEvent(SensorInformationChildFragment.TAB_CALL));
            //ExpandableListAdapter adapter = (ExpandableListAdapter)parent.getAdapter();
            ExpandableListAdapter adapter = (ExpandableListAdapter)parent.getAdapter();
            OrganisationDeviceSensorsResult d = (OrganisationDeviceSensorsResult) adapter.getChild(groupPosition,  childPosition);
            d.SensorID = d.SensorID;
            OrganisationDeviceSensorsResult deviceSensor = (OrganisationDeviceSensorsResult) adapter.getChild(groupPosition , childPosition);
            Object contact = adapter.getChild(groupPosition , childPosition);
           // OrganisationDeviceSensorsResult contact = listDataChild.get(groupPosition).getContacts().get(childPosition);
            //sensorID = deviceSensor.SensorID;
            //sensorID = contact.equals()

            ReportingGroup.get(childPosition);

            return true;
         }
      });
   } 

这是日志

01-11 11:42:30.328 22606-22606/com.claritech.simsentinelmobile D/dalvikvm: threadid=1: detach (group=0x41816ce0)
01-11 11:42:30.328 22606-22606/com.claritech.simsentinelmobile W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x41816ce0)
01-11 11:42:30.328 22606-22606/com.claritech.simsentinelmobile W/dalvikvm: threadid=1: uncaught exception occurred
01-11 11:42:30.329 22606-22606/com.claritech.simsentinelmobile W/System.err: java.lang.ClassCastException: android.widget.ExpandableListConnector cannot be cast to com.xera.deviceinsight.home.ExpandableListAdapter
01-11 11:42:30.329 22606-22606/com.claritech.simsentinelmobile W/System.err:     at com.xera.deviceinsight.home.CostCentreListFragment.onChildClick(CostCentreListFragment.java:88)
01-11 11:42:30.329 22606-22606/com.claritech.simsentinelmobile W/System.err:     at android.widget.ExpandableListView.handleItemClick(ExpandableListView.java:712)
01-11 11:42:30.330 22606-22606/com.claritech.simsentinelmobile W/System.err:     at android.widget.ExpandableListView.performItemClick(ExpandableListView.java:651)
01-11 11:42:30.330 22606-22606/com.claritech.simsentinelmobile W/System.err:     at android.widget.AbsListView$PerformClick.run(AbsListView.java:3014)
01-11 11:42:30.330 22606-22606/com.claritech.simsentinelmobile W/System.err:     at android.widget.AbsListView.run(AbsListView.java:3865)
01-11 11:42:30.331 22606-22606/com.claritech.simsentinelmobile W/System.err:     at android.os.Handler.handleCallback(Handler.java:808)
01-11 11:42:30.331 22606-22606/com.claritech.simsentinelmobile W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:103)
01-11 11:42:30.331 22606-22606/com.claritech.simsentinelmobile W/System.err:     at android.os.Looper.loop(Looper.java:193)
01-11 11:42:30.331 22606-22606/com.claritech.simsentinelmobile W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5299)
01-11 11:42:30.332 22606-22606/com.claritech.simsentinelmobile W/System.err:     at java.lang.reflect.Method.invokeNative(Native Method)
01-11 11:42:30.332 22606-22606/com.claritech.simsentinelmobile W/System.err:     at java.lang.reflect.Method.invoke(Method.java:515)
01-11 11:42:30.332 22606-22606/com.claritech.simsentinelmobile W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
01-11 11:42:30.332 22606-22606/com.claritech.simsentinelmobile W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
01-11 11:42:30.333 22606-22606/com.claritech.simsentinelmobile W/System.err:     at dalvik.system.NativeStart.main(Native Method)
01-11 11:42:30.333 22606-22606/com.claritech.simsentinelmobile W/dalvikvm: threadid=1: calling UncaughtExceptionHandler
01-11 11:42:30.335 22606-22606/com.claritech.simsentinelmobile E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                 Process: com.claritech.simsentinelmobile, PID: 22606
                                                                                 java.lang.ClassCastException: android.widget.ExpandableListConnector cannot be cast to com.xera.deviceinsight.home.ExpandableListAdapter
                                                                                     at com.xera.deviceinsight.home.CostCentreListFragment.onChildClick(CostCentreListFragment.java:88)
                                                                                     at android.widget.ExpandableListView.handleItemClick(ExpandableListView.java:712)
                                                                                     at android.widget.ExpandableListView.performItemClick(ExpandableListView.java:651)
                                                                                     at android.widget.AbsListView$PerformClick.run(AbsListView.java:3014)
                                                                                     at android.widget.AbsListView.run(AbsListView.java:3865)
                                                                                     at android.os.Handler.handleCallback(Handler.java:808)
                                                                                     at android.os.Handler.dispatchMessage(Handler.java:103)
                                                                                     at android.os.Looper.loop(Looper.java:193)
                                                                                     at android.app.ActivityThread.main(ActivityThread.java:5299)
                                                                                     at java.lang.reflect.Method.invokeNative(Native Method)
                                                                                     at java.lang.reflect.Method.invoke(Method.java:515)
                                                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
                                                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
                                                                                     at dalvik.system.NativeStart.main(Native Method)

尝试在以下语句中使用完全限定的 class 名称,即 -

listAdapter = new com.xera.deviceinsight.home.ExpandableListAdapter(this.getActivity(), listDataHeader, listDataChild);