【问题标题】:AndroidManifest.xml use integer ids stored in public.xml for themesAndroidManifest.xml 使用存储在 public.xml 中的整数 id 作为主题
【发布时间】:2016-06-23 06:17:27
【问题描述】:

这是我的文件的粗略概念。我继承了一堆使用public.xml 文件将ids 映射到themes 的代码。此代码抛出错误:

Error:(40, 24) Integer types not allowed (at 'theme' with value '0x7f09007a')

但是,当我将 android:theme="0x7f09007a" 替换为 android:theme="@style/myCoolTheme 时,一切正常。我需要能够使用这些ids,因为我继承的更多代码使用它们。我是否缺少使清单文件使用 public.xml? 中的 id 映射的东西

app/src/main/res/AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest ...
    <application
       android:theme="0x7f09007a"
       ...
    </application>
</manifest>

app/src/main/res/values/public.xml

<?xml version="1.0" encoding="utf-8"?>
    <resources>
       <public type="style" name="myCoolTheme" id="0x7f09007a" />
       ...
    </resources>

app/src/main/res/values/style.xml

<resources>
    <style name="AppTheme" 
        ...
    </style>
    <style name="myCoolTheme" parent="@style/AppTheme" />
</resources>

【问题讨论】:

    标签: java android android-xml


    【解决方案1】:

    参考this post,我相信@style/myCoolTheme的使用是正确的,因为你使用的是public.xmlname="myCoolTheme"

    id="" 属性的唯一目的是将该整数值合并到R.java 中,而不被其他 XML 文件引用。

    【讨论】:

      【解决方案2】:

      您是否尝试过将 xml 中的资源名称重命名为相同的名称?是否有必要将样式命名为“myCoolTheme”?如果没有,这可能会奏效。

      <?xml version="1.0" encoding="utf-8"?>
          <resources>
             <public type="style" name="0x7f09007a" id="0x7f09007a" />
             ...
          </resources
      

      如果重命名没有问题,你可以在 AndroidManifest.xml 中使用以下内容

      android:theme="@style/0x7f09007a"a
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-04-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-08-17
        • 1970-01-01
        相关资源
        最近更新 更多