首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

在设立Text时提示Should pass resolved color instead of resource id here

2012-10-17 
在设置Text时提示Should pass resolved color instead of resource id here我是这样设置文本颜色的public

在设置Text时提示Should pass resolved color instead of resource id here

我是这样设置文本颜色的

public void addText(CharSequence cs) {
for (int i = 0; i < cs.length(); i++) {
TextView tv = new TextView(activity);
tv.setTextColor(R.color.pantry_blue);
tv.setTextSize(36);
tv.setText(cs.charAt(i) + "");
lLayout.addView(tv);
}
}

出现提示:

Should pass resolved color instead of resource id here: getResources().getColor(R.color.app_separator)

Issue: Looks for calls to setColor where a resource id is passed instead of a resolved color

Id: ResourceAsColor

 

Methods that take a color in the form of an integer should be passed an RGB triple, not the actual color resource id. You must call getResources().getColor(resource) to resolve the actual color value first.

到底是什么原因呢,还请各位指点

热点排行