Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法在eclipse中使用color.xml文件_Java_Android_Xml_Eclipse - Fatal编程技术网

Java 无法在eclipse中使用color.xml文件

Java 无法在eclipse中使用color.xml文件,java,android,xml,eclipse,Java,Android,Xml,Eclipse,我在那个名字@color/red上找不到资源。我不知道为什么我的displayStudentInfo.activity上会识别出这些颜色。请帮忙 这是我的colors.xml文件 <?xml version="1.0" encoding="utf-8"?> <resources> <color name="blue">#0000ff</color> <color name="red">#ff0000</color>

我在那个名字@color/red上找不到资源。我不知道为什么我的displayStudentInfo.activity上会识别出这些颜色。请帮忙

这是我的colors.xml文件

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <color name="blue">#0000ff</color>
  <color name="red">#ff0000</color>
  <color name="green">#00ff00</color>
  <color name="black">#000000</color>

</resources>
这是我的DisplayStudentInfo.activity文件

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
 >

<TextView    android:id="@+id/text1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/line1"
    android:textColor="@color/red" />

<TextView    android:id="@+id/text2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/line2" />

<TextView android:id="@+id/text3"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/line3"/>
<TextView android:id="@+id/text4"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/line4"/>

我是android新手,但我认为你的问题在于你的colors.xml文件。 您的文件应如下所示:


为什么要将上面的xml文件称为类?我不是要更改它的DisplayStudentInfo.activity这是文件的确切名称吗?没有它的activity\u display\u student\u info。xml@user3242607蓝色行吗?
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <item name="blue" type="color">#FF33B5E5</item>
    <item name="purple" type="color">#FFAA66CC</item>
    <item name="green" type="color">#FF99CC00</item>
    <item name="orange" type="color">#FFFFBB33</item>
    <item name="red" type="color">#FFFF4444</item>
    <item name="darkblue" type="color">#FF0099CC</item>
    <item name="darkpurple" type="color">#FF9933CC</item>
    <item name="darkgreen" type="color">#FF669900</item>
    <item name="darkorange" type="color">#FFFF8800</item>
    <item name="darkred" type="color">#FFCC0000</item>

    <integer-array name="androidcolors">
        <item>@color/blue</item>
        <item>@color/purple</item>
        <item>@color/green</item>
        <item>@color/orange</item>
        <item>@color/red</item>
        <item>@color/darkblue</item>
        <item>@color/darkpurple</item>
        <item>@color/darkgreen</item>
        <item>@color/darkorange</item>
        <item>@color/darkred</item>
    </integer-array>

</resources>