android中的ClassCastException,同时实现手动创建的新支持类

时间:2018-07-12 03:40:19

标签: android classcastexception

我已包含要实现的这段代码

final Superclass superclass =(Superclass) getApplicationContext();

错误日志:

E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.kanesky.moneyad, PID: 11723
                  java.lang.ClassCastException: android.app.ContextImpl cannot be cast to com.kanesky.moneyad.Superclass
                      at com.kanesky.moneyad.LoginActivity.login(LoginActivity.java:75)
                      at com.kanesky.moneyad.LoginActivity$1.onClick(LoginActivity.java:50)
                      at android.view.View.performClick(View.java:5619)
                      at android.view.View$PerformClick.run(View.java:22295)
                      at android.os.Handler.handleCallback(Handler.java:754)
                      at android.os.Handler.dispatchMessage(Handler.java:95)
                      at android.os.Looper.loop(Looper.java:163)
                      at android.app.ActivityThread.main(ActivityThread.java:6342)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)

0 个答案:

没有答案