我在网上看到有代码这样的,在布局文件里面,访问drawable的颜色
<TextView
        android:id="@+id/TextView01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@drawable/black"    </TextView>
但是我这里eclipse老是报错,请问怎么改?

解决方案 »

  1.   

    drawable里面是不是有标准颜色的啊?好久之前我访问过,详细情况记不清了,反正不是我定义的,我是访问android定义的颜色的
      

  2.   

    black应该是xml,里面包含着color信息。
      

  3.   

    系统定义了很多颜色,里面有black,你可以之际访问,不要自己定义
      

  4.   


    楼主没有发现你的xml文件代码写错了吗?应该这样写的,如下所示:<TextView
      android:id="@+id/TextView01"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textColor="@drawable/black" >
    </TextView>
    或者这样写:
    <TextView
      android:id="@+id/TextView01"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textColor="@drawable/black"/>
      

  5.   


    楼主没有发现你的xml文件代码写错了吗?应该这样写的,如下所示:<TextView
      android:id="@+id/TextView01"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textColor="@drawable/black" >
    </TextView>
    或者这样写:
    <TextView
      android:id="@+id/TextView01"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textColor="@drawable/black"/>
      

  6.   

    android:textColor="@android:color/black"
      

  7.   

    代码中访问系统颜色:
    R.color.black;XML中访问系统颜色:
    前提有color.xml, android:textColor="@color/black", 或者直接用android:textColor="#000000"