定义我自己的 Android 主题时出现问题

发布于 2024-09-24 08:29:23 字数 1455 浏览 3 评论 0原文

这个 XML 有什么问题吗?我没有收到任何编译时错误,但每当我尝试编辑它时,Eclipse 都会给我一个空指针异常。为什么?

/res/values/styles.xml

<?xml version="1.0" encoding="utf-8"?>
    <resources>
      <!-- Base application theme is the default theme. -->
      <style name="Theme" parent="android:Theme">
      </style>

      <!-- Variation on our application theme that has a translucent
     background. -->
      <style name="Theme.Translucent">
        <item name="android:windowBackground">@drawable/translucent_background</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:colorForeground">#fff</item>
      </style>

      <!-- Variation on our application theme that has a transparent
    background; this example completely removes the background,
    allowing the activity to decide how to composite. -->
      <style name="Theme.Transparent">
        <item name="android:windowBackground">@drawable/transparent_background</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:colorForeground">#fff</item>
      </style>
      <style name="TextAppearance.Theme.PlainText" parent="android:TextAppearance.Theme">
        <item name="android:textStyle">normal</item>
      </style>

    </resources>

Is there anything wrong with this XML? I don't get any compile time errors, but anytime I try to edit it, Eclipse gives me a nullpointerexception. Why?

/res/values/styles.xml

<?xml version="1.0" encoding="utf-8"?>
    <resources>
      <!-- Base application theme is the default theme. -->
      <style name="Theme" parent="android:Theme">
      </style>

      <!-- Variation on our application theme that has a translucent
     background. -->
      <style name="Theme.Translucent">
        <item name="android:windowBackground">@drawable/translucent_background</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:colorForeground">#fff</item>
      </style>

      <!-- Variation on our application theme that has a transparent
    background; this example completely removes the background,
    allowing the activity to decide how to composite. -->
      <style name="Theme.Transparent">
        <item name="android:windowBackground">@drawable/transparent_background</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:colorForeground">#fff</item>
      </style>
      <style name="TextAppearance.Theme.PlainText" parent="android:TextAppearance.Theme">
        <item name="android:textStyle">normal</item>
      </style>

    </resources>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦醒灬来后我 2024-10-01 08:29:23

我也见过几次这样的情况。我做了一个Project->Clean,然后重新启动了eclipse。当它回来时,问题就消失了。

I have seen this a couple times as well. I did a Project->Clean and then restarted eclipse. When it came back up the problem went away.

揽清风入怀 2024-10-01 08:29:23

我立即没有发现什么,只需确保您的 res/drawable 文件夹中有 transparent_backgroundtranslucent_background 即可。

Nothing pops out at me right away, just make sure you have transparent_background and translucent_background in your res/drawable folder.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文