這裏是我的顏色XML問題設置TextView的顏色
<resources>
<drawable name="red">#7f00</drawable>
<drawable name="blue">#770000ff</drawable>
<drawable name="green">#7700ff00</drawable>
<drawable name="yellow">#77ffff00</drawable>
<drawable name="screen_background_black">#ff000000</drawable>
<drawable name="translucent_background">#e0000000</drawable>
<drawable name="transparent_background">#00000000</drawable>
<color name="solid_red">#ED1C24</color>
<color name="solid_blue">#0000ff</color>
<color name="solid_green">#39B54A</color>
<color name="solid_yellow">#ffffff00</color>
</resources>
這裏是我的Java代碼:
if (floatedChange < 0)
changeText.setTextColor(R.color.solid_red); //red
else
changeText.setTextColor(R.color.solid_green); //green
這工作,當我使用Color.RED或Color.GREEN,但是當我用我的自己的顏色。顏色不顯示。
爲什麼?
該礦位於/res/values/color.xml – 2010-09-24 17:02:05
你有沒有在一開始的 「<?xml的...」 標籤? – Wroclai 2010-09-24 17:04:16
我在開頭有<?xml標籤。我將我的代碼更改爲:changeText.setTextColor(R.style.solid_red); //但是solid_red找不到 – 2010-09-24 17:08:29