为了账号安全,请及时绑定邮箱和手机立即绑定

((AppCompatActivity) getActivity()).setSupportActionBar(toolbar)报错

((AppCompatActivity) getActivity()).setSupportActionBar(toolbar)报错

  Process: com.nsisoft.charmcampus.charmcampus, PID: 2835                  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nsisoft.charmcampus.charmcampus/com.nsisoft.charmcampus.charmcampus.MainActivity}: java.lang.ClassCastException: com.nsisoft.charmcampus.charmcampus.MainActivity cannot be cast to android.support.v7.app.AppCompatActivity                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)                      at android.app.ActivityThread.-wrap12(ActivityThread.java)                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)                      at android.os.Handler.dispatchMessage(Handler.java:102)                      at android.os.Looper.loop(Looper.java:154)                      at android.app.ActivityThread.main(ActivityThread.java:6077)                      at java.lang.reflect.Method.invoke(Native Method)                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)                   Caused by: java.lang.ClassCastException: com.nsisoft.charmcampus.charmcampus.MainActivity cannot be cast to android.support.v7.app.AppCompatActivity                      at com.nsisoft.charmcampus.charmcampus.Auditorium.onCreateView(Auditorium.java:73)                      at android.support.v4.app.Fragment.performCreateView(Fragment.java:2080)                      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1108)                      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1290)                      at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:801)                      at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1677)                      at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:388)                      at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:604)                      at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1248)                      at android.app.Activity.performStart(Activity.java:6681)                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2609)                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)                       at android.app.ActivityThread.-wrap12(ActivityThread.java)                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)                       at android.os.Handler.dispatchMessage(Handler.java:102)                       at android.os.Looper.loop(Looper.java:154)                       at android.app.ActivityThread.main(ActivityThread.java:6077)                       at java.lang.reflect.Method.invoke(Native Method)                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 
查看完整描述

1 回答

已采纳
?
一条小咸鱼

TA贡献457条经验 获得超255个赞


你用的第三方库的MainActivity不能强制转换为AppCompactActivity

查看完整回答
反对 回复 2017-03-07
  • 1 回答
  • 0 关注
  • 2060 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信