gpt4 book ai didi

android - 在 Android Manifest.xml 文件上更改 Theme.Holo 无法在 Android 上运行

转载 作者:行者123 更新时间:2023-11-29 16:01:33 25 4
gpt4 key购买 nike

我是 Android 应用程序开发的新手,最近在 Styling the Action Bar page 上碰壁了.

每次我将主题更改为 android:theme="@android:style/Theme.Holo.Light" 都不允许程序在 android 上运行,并显示一条消息“很遗憾,程序停止了。”每次我尝试运行它。奇怪的是,它在 Eclipse 上保存得很好,没有错误。

这是我的 list 文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstappv2"
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.example.myfirstappv2.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>
<activity
android:name="com.example.myfirstappv2.DisplayMessageActivity"
android:label="@string/title_activity_display_message"
android:parentActivityName="com.example.myfirstappv2.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.myfirstappv2.MainActivity" />
</activity>
</application>

</manifest>

日志:

06-15 21:17:24.748: E/AndroidRuntime(5350): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myfirstappv2/com.example.myfirstappv2.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

最佳答案

如果您的 Activity 是 ActionBarActivity,那么您需要使用其中一种 Theme.AppCompat 变体(即 Theme.AppCompatTheme.AppCompat.Light, &c).

来自Styling the Action Bar页:

Note: If you are using the Support Library APIs for the action bar, then you must use (or override) the Theme.AppCompat family of styles (rather than the Theme.Holo family, available in API level 11 and higher). In doing so, each style property that you declare must be declared twice: once using the platform's style properties (the android: properties) and once using the style properties included in the Support Library (the appcompat.R.attr properties—the context for these properties is actually your app).

不要忘记“添加两次属性”部分。

关于android - 在 Android Manifest.xml 文件上更改 Theme.Holo 无法在 Android 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24235498/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com