简体   繁体   English

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

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

I have an expandable list view however when I expand it and click on the child I get an error that reads我有一个可扩展的列表视图,但是当我展开它并单击子项时,我收到一个错误消息

FATAL EXCEPTION: main Process: com.claritech.simsentinelmobile, PID: 22606 java.lang.ClassCastException: android.widget.ExpandableListConnector cannot be cast to com.xera.deviceinsight.home.ExpandableListAdapter致命异常:主进程:com.claritech.simsentinelmobile,PID:22606 java.lang.ClassCastException:android.widget.ExpandableListConnector 无法转换为 com.xera.deviceinsight.home.ExpandableListAdapter

This is the line that is throwing the error这是抛出错误的行

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

and this is the entire method I am trying to use an adapter to retrieve an object(details about the clicked child from server using retrofit)这是我尝试使用适配器检索对象的整个方法(有关使用改造从服务器单击的子项的详细信息)

 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;
         }
      });
   } 

This is the log这是日志

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$1.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$3.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$1.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$3.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)

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我无法在我的扩展列表适配器中使用openFileInput()方法 - I am not able to use openFileInput() method in my Expandable list adapter ArrayIndexOutOfBoundsException-我不明白为什么收到此错误 - ArrayIndexOutOfBoundsException - I dont understand why I am getting this error 我正在发生致命异常 - I am getting FATAL EXCEPTION 不确定为什么尝试调用我的方法时会出现异常 - Not sure why I am getting an exception when trying to call my method 我的Java代码有缺陷,但是我不明白为什么 - My java code is flawed, but i dont understand why 为什么我在构造函数中收到StackOverflowError异常 - Why am I getting a StackOverflowError exception in my constructor 为什么我的 Spring Boot 应用程序出现异常? - Why am I getting exception in my Spring Boot Application? 为什么在使用 containsKey 方法后我的列表中出现重复项 - why i am getting duplicates in my list after using containsKey method 试图了解为什么我在休眠状态下收到锁定超时异常 - Trying to understand why I am getting a lock timeout exception with hibernate 我不明白我的输出。 为什么我两次得到相同的东西? - I do not understand my output. Why am I getting the same thing twice?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM