老师,这是闪退提示的信息,看不太懂

老师,这是闪退提示的信息,看不太懂

05-09 22:39:09.401 2891-2891/com.example.a25071.myapplication D/AndroidRuntime: Shutting down VM
                                                                                
                                                                                
                                                                                --------- beginning of crash
05-09 22:39:09.410 2891-2891/com.example.a25071.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                Process: com.example.a25071.myapplication, PID: 2891
                                                                                java.lang.ClassCastException: com.example.a25071.menudemo.MainActivity$3 cannot be cast to android.view.ActionMode$Callback
                                                                                    at com.example.a25071.menudemo.MainActivity$1.onLongClick(MainActivity.java:34)
                                                                                    at android.view.View.performLongClickInternal(View.java:6404)
                                                                                    at android.view.View.performLongClick(View.java:6362)
                                                                                    at android.widget.TextView.performLongClick(TextView.java:11004)
                                                                                    at android.view.View.performLongClick(View.java:6380)
                                                                                    at android.view.View$CheckForLongPress.run(View.java:24942)
                                                                                    at android.os.Handler.handleCallback(Handler.java:790)
                                                                                    at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                    at android.os.Looper.loop(Looper.java:192)
                                                                                    at android.app.ActivityThread.main(ActivityThread.java:6706)
                                                                                    at java.lang.reflect.Method.invoke(Native Method)
                                                                                    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
                                                                                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:826)
05-09 22:39:09.493 2891-2891/com.example.a25071.myapplication I/Process: Sending signal. PID: 2891 SIG: 9

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

2回答
irista23 2019-05-12 09:34:25

你检查下代码中cb定义的类型是否正确

http://img1.sycdn.imooc.com//climg/5cd7780a0001764811440448.jpg

好帮手慕雪 2019-05-10 09:55:32

http://img1.sycdn.imooc.com//climg/5cd4d9a10001468607550101.jpg

提示的是类型不匹配造成的。你做强制类型转换之类的了吗?你看一下MainActivity.java第34行附近,是它引起的。祝:学习愉快

  • 提问者 慕设计3223617 #1
    startActionMode((android.view.ActionMode.Callback) cb); 这是34行的代码,进行过强制转化的,就是闪退,之前发给您的代码也就是这样的
    2019-05-10 23:47:06
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师