Reputation: 1830
Hi I am new to Android development, I'm trying to set a activity's theme by including the theme in activity : <activity android:name="AddEventActivity"
android:theme="@android:style/Theme.Dialog"></activity>
When running the application I get the following exception :
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
When I remove the code from the AndroidManifest.xml it works.
What I want to do is display an Activity like a Dialog by using a theme.
Is android:theme="@android:style/Theme.Dialog" a standard theme witch is included automatically in my project or should I add it, and where? or what am I doing wrong?
Any help will be appreciated.
Upvotes: 0
Views: 460
Reputation: 17171
My guess is that getActionBar()
at AddEventActivity.java:87
is returning null because that theme doesn't support it.
Upvotes: 4