1.引用color 包下的资源
convertView.setBackgroundColor(getResources().getColor(R.color.colorMaterial));
注:通过获得资源文件进行设置。根据不同的情况R.color.red也可以是R.string.red或者R.drawable.red,当然前提是需要在相应的配置文件里做相应 的配置,如(xml 标签):
<color name="red">#FF0000</color>
<drawable name="red">#FF0000</drawable>
<string name="red">#FF0000</string>
2.使用系统自带的颜色类
tText.setTextColor(android.graphics.Color.RED);//系统自带的颜色类
3.设置16进制的数值
tText.setTextColor(0xffff00ff);
4.利用Color类
tText.setTextColor(android.graphics.Color.parseColor("#87CEFA")) ;