1

我是 Mono for Android(使用 MonoDevelop)和一般 Android 开发的新手。我想创建一个应用程序范围的主题。此主题只需将所有 EditText 字段的背景颜色设置为灰色(只是为了测试功能)。

在 Resources/values 文件夹中,我创建了 2 个文件:

样式.xml

<resources>
<style name="tstEditText" parent="android:style/Widget.EditText">
    <item name="android:background">#cccccc</item>
</style>
</resources>

主题.xml

<resources>
<style name="MyApplicationTheme" parent="android:Theme">    
    <item name="android:editTextStyle">@style/txtEditText</item>
</style>
</resources>

之后我修改了 ApplicationManifest.xml

<application android:label="MyApplication" android:theme="MyApplicationTheme"></application>

当我尝试构建代码时,我收到以下错误消息:“错误:不允许字符串类型(在 'theme' 处,值为 'MyApplicationTheme')。 ” AndroidManifest.xml 中的第一个活动节点上引发错误MonoDevelop 在构建时生成。

显然我错过了一些东西,但我不知道......提前感谢您的帮助!

4

1 回答 1

3

在清单 XML 中,您需要像这样指定主题:

android:theme="@style/MyApplicationTheme"
于 2012-06-16T15:37:52.830 回答