0

指针应用程序扩展应用程序。

private pointerApplication getPoa() {
    pointerApplication poa = (pointerApplication) getApplication();
    return poa;
} 

和错误:

   06-23 11:21:30.276: E/AndroidRuntime(1374): FATAL EXCEPTION: main
06-23 11:21:30.276: E/AndroidRuntime(1374): java.lang.ClassCastException: android.app.Application cannot be cast to com.startup.tryingpointers.pointerApplication
06-23 11:21:30.276: E/AndroidRuntime(1374):     at com.startup.tryingpointers.AddsubjectList.addSubject(AddsubjectList.java:49)
06-23 11:21:30.276: E/AndroidRuntime(1374):     at com.startup.tryingpointers.AddsubjectList$1.onClick(AddsubjectList.java:33)
06-23 11:21:30.276: E/AndroidRuntime(1374):     at android.view.View.performClick(View.java:4204)
06-23 11:21:30.276: E/AndroidRuntime(1374):     at android.view.View$PerformClick.run(View.java:17355)
06-23 11:21:30.276: E/AndroidRuntime(1374):     at android.os.Handler.handleCallback(Handler.java:725)
06-23 11:21:30.276: E/AndroidRuntime(1374):     at android.os.Handler.dispatchMessage(Handler.java:92)
06-23 11:21:30.276: E/AndroidRuntime(1374):     at android.os.Looper.loop(Looper.java:137)
06-23 11:21:30.276: E/AndroidRuntime(1374):     at android.app.ActivityThread.main(ActivityThread.java:5041)
06-23 11:21:30.276: E/AndroidRuntime(1374):     at java.lang.reflect.Method.invokeNative(Native Method)
06-23 11:21:30.276: E/AndroidRuntime(1374):     at java.lang.reflect.Method.invoke(Method.java:511)
06-23 11:21:30.276: E/AndroidRuntime(1374):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-23 11:21:30.276: E/AndroidRuntime(1374):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-23 11:21:30.276: E/AndroidRuntime(1374):     at dalvik.system.NativeStart.main(Native Method)
4

2 回答 2

1

确保在 中AndroidManifest.xml,您已使用正确的类名声明了 tag的android:name属性:application

<application
    android:name=".pointerApplication" >
</application>
于 2013-06-23T11:45:06.557 回答
0

如果仍然无法正常工作,请尝试清理项目

于 2013-06-23T13:00:20.287 回答