我在 /res/values/colors.xml 下的 Android 应用程序中创建了一个 colors.xml 文件。内容是...
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="Green">#00ff00</color>
</resources>
我尝试使用...更新我的 TableRow 的背景
TableRow test = (TableRow)findViewById(R.id.tableRow2);
test.setBackgroundColor(R.color.Green);
这不会将其设置为绿色,而是将其设置为灰色。无论我将什么值添加到 colors.xml 文件中,它始终是相同的灰色。然而,这确实有效......
TableRow test = (TableRow)findViewById(R.id.tableRow2);
test.setBackgroundColor(android.graphics.Color.GREEN);
我的 colors.xml 有问题吗?