您好我是Android开发的新手,我正在尝试通过将主题包含在活动中来设置活动的主题:<activity android:name="AddEventActivity"
android:theme="@android:style/Theme.Dialog"></activity>
运行应用程序时,我得到以下异常:
07-23 13:00:34.965: E/AndroidRuntime(3599): FATAL EXCEPTION: main
07-23 13:00:34.965: E/AndroidRuntime(3599): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sadev.z/com.sadev.z.AddEventActivity}: java.lang.NullPointerException
07-23 13:00:34.965: E/AndroidRuntime(3599): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
07-23 13:00:34.965: E/AndroidRuntime(3599): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
07-23 13:00:34.965: E/AndroidRuntime(3599): at android.app.ActivityThread.access$600(ActivityThread.java:140)
07-23 13:00:34.965: E/AndroidRuntime(3599): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
07-23 13:00:34.965: E/AndroidRuntime(3599): at android.os.Handler.dispatchMessage(Handler.java:99)
07-23 13:00:34.965: E/AndroidRuntime(3599): at android.os.Looper.loop(Looper.java:137)
07-23 13:00:34.965: E/AndroidRuntime(3599): at android.app.ActivityThread.main(ActivityThread.java:4898)
07-23 13:00:34.965: E/AndroidRuntime(3599): at java.lang.reflect.Method.invokeNative(Native Method)
07-23 13:00:34.965: E/AndroidRuntime(3599): at java.lang.reflect.Method.invoke(Method.java:511)
07-23 13:00:34.965: E/AndroidRuntime(3599): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
07-23 13:00:34.965: E/AndroidRuntime(3599): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
07-23 13:00:34.965: E/AndroidRuntime(3599): at dalvik.system.NativeStart.main(Native Method)
07-23 13:00:34.965: E/AndroidRuntime(3599): Caused by: java.lang.NullPointerException
07-23 13:00:34.965: E/AndroidRuntime(3599): at com.sadev.z.AddEventActivity.onCreate(AddEventActivity.java:87)
07-23 13:00:34.965: E/AndroidRuntime(3599): at android.app.Activity.performCreate(Activity.java:5206)
07-23 13:00:34.965: E/AndroidRuntime(3599): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
07-23 13:00:34.965: E/AndroidRuntime(3599): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
07-23 13:00:34.965: E/AndroidRuntime(3599): ... 11 more
当我从AndroidManifest.xml中删除代码时,它可以正常工作。
我想要做的是使用主题显示像对话框一样的活动。
android:theme =“@ android:style / Theme.Dialog”标准主题女巫是自动包含在我的项目中还是应该添加它,在哪里?或者我做错了什么?
任何帮助将不胜感激。
答案 0 :(得分:4)
我的猜测是getActionBar()
AddEventActivity.java:87
返回null,因为该主题不支持它。