跪求解救!!!!!有大神对树形菜单熟悉吗?来个大神看看啊

TreeViewAdapter这个是适配器点击事件里有个onToggle方法我加上这个方法会闪退,
我把这个方法去掉就可以正常运行这是为什么?是不是我还要添加什么属性才不会闪退。这个方法是这样的

   @Override
                                    public void onToggle(boolean isExpand, RecyclerView.ViewHolder holder) {
                                        DirectoryNodeBinder.ViewHolder dirViewHolder = (DirectoryNodeBinder.ViewHolder) holder;
                                        final ImageView ivArrow = dirViewHolder.getIvArrow();
                                        int rotateDegree = isExpand ? 90 : -90;
                                        ivArrow.animate().rotationBy(rotateDegree)
                                                .start();
                                    }

报错的日志是这样的如下:

08-02 17:34:37.877 15792-15792/com.chenxi.bimquanziguankong D/AndroidRuntime: Shutting down VM
08-02 17:34:37.879 15792-15792/com.chenxi.bimquanziguankong E/CrashHandler: In thread: Thread[main,5,main]
    UncaughtException detected: java.lang.ClassCastException: com.chenxi.bimquanziguankong.viewbinder.FileNodeBinder$ViewHolder cannot be cast to com.chenxi.bimquanziguankong.viewbinder.DirectoryNodeBinder$ViewHolder
        at com.chenxi.bimquanziguankong.activity.workspace.NewWorkSpaceActivity$2$1$1.onToggle(NewWorkSpaceActivity.java:187)
        at com.chenxi.bimquanziguankong.activity.workspace.NewWorkSpaceActivity$2$1$1.onClick(NewWorkSpaceActivity.java:132)
        at tellh.com.recyclertreeview_lib.TreeViewAdapter$1.onClick(TreeViewAdapter.java:102)
        at android.view.View.performClick(View.java:4780)
        at android.view.View$PerformClick.run(View.java:19866)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5293)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

跪求大神解救啊!!!!!!!!!!

1个回答

qq_43544413
qq_43544413 这个方法是我用来展示箭头的
8 个月之前 回复
qq_43544413
qq_43544413 你这个我找不到我想要的啊!我想问下 DirectoryNodeBinder.ViewHolder dirViewHolder = (DirectoryNodeBinder.ViewHolder) holder;这句代码为啥报错?我自定义了一个(DirectoryNodeBinder.ViewHolder)继承TreeViewBinder.ViewHolder然后就报如上的错误我表示很晕
8 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问