定义我自己的Android主题的问题

时间:2010-09-23 17:37:31

标签: android xml themes

这个XML有什么问题吗?我没有得到任何编译时错误,但无论何时我尝试编辑它,Eclipse都会给我一个nullpointerexception。为什么呢?

/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>

2 个答案:

答案 0 :(得分:0)

我没有立刻突然出现,只要确保transparent_background文件夹中有translucent_backgroundres/drawable

答案 1 :(得分:0)

我也见过几次。我做了一个Project-&gt; Clean然后重启了eclipse。当它恢复时问题就消失了。