在android清单中更改主题时强制关闭

时间:2014-06-29 14:51:17

标签: android android-activity themes

我已经改变了一些活动的主题,但是当我想要运行AVD时,请转到强制停止。 这是我的活动清单:

<activity
        android:name="com.example.gpsportalsms.LoginActivity"
        android:theme="@android:style/Theme.Translucent."
        android:label="@string/title_activity_login" >
        <intent-filter>

这是我的xml活动:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.gpsportalsms.LoginActivity"
android:background="@drawable/background3"
tools:ignore="MergeRootFrame" >


</FrameLayout>

我在下面添加了LogCat:

 06-29 16:10:24.015: W/dalvikvm(1420): threadid=1: thread exiting with uncaught  exception (group=0xa4ceeb20)
 06-29 16:10:24.015: E/AndroidRuntime(1420): FATAL EXCEPTION: main
 06-29 16:10:24.015: E/AndroidRuntime(1420): Process: com.example.gpsportalsms, PID: 1420
 06-29 16:10:24.015: E/AndroidRuntime(1420): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.gpsportalsms/com.example.gpsportalsms.NotifySMSReceived}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
 06-29 16:10:24.015: E/AndroidRuntime(1420):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
 06-29 16:10:24.015: E/AndroidRuntime(1420):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
 06-29 16:10:24.015: E/AndroidRuntime(1420):    at android.app.ActivityThread.access$800(ActivityThread.java:135)
  06-29 16:10:24.015: E/AndroidRuntime(1420):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
  06-29 16:10:24.015: E/AndroidRuntime(1420):   at android.os.Handler.dispatchMessage(Handler.java:102)
  06-29 16:10:24.015: E/AndroidRuntime(1420):   at android.os.Looper.loop(Looper.java:136)
 06-29 16:10:24.015: E/AndroidRuntime(1420):    at android.app.ActivityThread.main(ActivityThread.java:5017)
  06-29 16:10:24.015: E/AndroidRuntime(1420):   at java.lang.reflect.Method.invokeNative(Native Method)
 06-29 16:10:24.015: E/AndroidRuntime(1420):    at java.lang.reflect.Method.invoke(Method.java:515)
 06-29 16:10:24.015: E/AndroidRuntime(1420):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
 06-29 16:10:24.015: E/AndroidRuntime(1420):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
 06-29 16:10:24.015: E/AndroidRuntime(1420):    at dalvik.system.NativeStart.main(Native Method)
 06-29 16:10:24.015: E/AndroidRuntime(1420): Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
 06-29 16:10:24.015: E/AndroidRuntime(1420):    at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:108)
 06-29 16:10:24.015: E/AndroidRuntime(1420):    at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:57)
 06-29 16:10:24.015: E/AndroidRuntime(1420):    at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
 06-29 16:10:24.015: E/AndroidRuntime(1420):    at com.example.gpsportalsms.NotifySMSReceived.onCreate(NotifySMSReceived.java:20)
 06-29 16:10:24.015: E/AndroidRuntime(1420):    at android.app.Activity.performCreate(Activity.java:5231)
 06-29 16:10:24.015: E/AndroidRuntime(1420):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
 06-29 16:10:24.015: E/AndroidRuntime(1420):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
 06-29 16:10:24.015: E/AndroidRuntime(1420):    ... 11 more

有什么问题?

2 个答案:

答案 0 :(得分:0)

删除“。”在Theme.Translucent。

使用此

 <activity
    android:name="com.example.gpsportalsms.LoginActivity"
    android:theme="@android:style/Theme.Translucent"
    android:label="@string/title_activity_login" >

答案 1 :(得分:0)

快速搜索让我想到了这个问题:How to make an Android Translucent theme a little darker?

然而,上述问题与您的问题并无太大关系,但提供了一些参考。哈文试过了。

正如它所说的代码必须像

<activity
        android:name="com.example.gpsportalsms.LoginActivity"
        android:theme="@android:style/Theme.Translucent"
        android:label="@string/title_activity_login" >

请注意&#39; &#39;不应该在那里。