Holo主题没有在启动画面上工作...应用程序崩溃

时间:2014-06-18 05:12:43

标签: android splash-screen android-holo-everywhere

您好我想为我的应用添加holo主题,但是当我检查我的启动图形布局时,它似乎不起作用,我的应用程序崩溃了。我想为整个应用添加holo主题。此外,我想摆脱闪屏之前的屏幕。我不知道该怎么做

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sachinda.myfirstapp"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="19" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Holo">
    <activity
        android:name="com.sachinda.myfirstapp.MainActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

这是logcat

06-18 01:16:54.390: I/Process(7860): Sending signal. PID: 7860 SIG: 9
06-18 01:16:55.530: D/HyLog(8955): I : /data/font/config/sfconfig.dat, No such file or directory (2)
06-18 01:16:55.530: D/HyLog(8955): I : /data/font/config/dfactpre.dat, No such file or directory (2)
06-18 01:16:55.530: D/HyLog(8955): I : /data/font/config/sfconfig.dat, No such file or directory (2)
06-18 01:16:55.570: D/AndroidRuntime(8955): Shutting down VM
06-18 01:16:55.570: W/dalvikvm(8955): threadid=1: thread exiting with uncaught exception (group=0x41ae6e48)
06-18 01:16:55.570: E/AndroidRuntime(8955): FATAL EXCEPTION: main
06-18 01:16:55.570: E/AndroidRuntime(8955): Process: com.sachinda.myfirstapp, PID: 8955
06-18 01:16:55.570: E/AndroidRuntime(8955): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sachinda.myfirstapp/com.sachinda.myfirstapp.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
06-18 01:16:55.570: E/AndroidRuntime(8955):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2200)
06-18 01:16:55.570: E/AndroidRuntime(8955):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
06-18 01:16:55.570: E/AndroidRuntime(8955):     at android.app.ActivityThread.access$800(ActivityThread.java:139)
06-18 01:16:55.570: E/AndroidRuntime(8955):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200)
06-18 01:16:55.570: E/AndroidRuntime(8955):     at android.os.Handler.dispatchMessage(Handler.java:102)
06-18 01:16:55.570: E/AndroidRuntime(8955):     at android.os.Looper.loop(Looper.java:136)
06-18 01:16:55.570: E/AndroidRuntime(8955):     at android.app.ActivityThread.main(ActivityThread.java:5105)
06-18 01:16:55.570: E/AndroidRuntime(8955):     at java.lang.reflect.Method.invokeNative(Native Method)
06-18 01:16:55.570: E/AndroidRuntime(8955):     at java.lang.reflect.Method.invoke(Method.java:515)
06-18 01:16:55.570: E/AndroidRuntime(8955):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
06-18 01:16:55.570: E/AndroidRuntime(8955):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
06-18 01:16:55.570: E/AndroidRuntime(8955):     at dalvik.system.NativeStart.main(Native Method)
06-18 01:16:55.570: E/AndroidRuntime(8955): Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
06-18 01:16:55.570: E/AndroidRuntime(8955):     at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:111)
06-18 01:16:55.570: E/AndroidRuntime(8955):     at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)
06-18 01:16:55.570: E/AndroidRuntime(8955):     at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
06-18 01:16:55.570: E/AndroidRuntime(8955):     at com.sachinda.myfirstapp.MainActivity.onCreate(MainActivity.java:24)
06-18 01:16:55.570: E/AndroidRuntime(8955):     at android.app.Activity.performCreate(Activity.java:5275)
06-18 01:16:55.570: E/AndroidRuntime(8955):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
06-18 01:16:55.570: E/AndroidRuntime(8955):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2164)
06-18 01:16:55.570: E/AndroidRuntime(8955):     ... 11 more

1 个答案:

答案 0 :(得分:2)

您的活动可能会扩展ActionbarActivity,在这种情况下您需要Theme.AppCompat主题(或后代)。

你有什么

 android:theme="@android:style/Theme.Holo">

您的主题不是来自AppCompat

有无

 android:theme="@style/Theme.AppCompat

AppCompat

提取的主题

引用文档

使用支持库时,您必须改为使用Theme.AppCompat主题:

Theme.AppCompat for the "dark" theme.
Theme.AppCompat.Light for the "light" theme.
Theme.AppCompat.Light.DarkActionBar for the light theme with a dark action bar.