我有一个列表,并为此编写了一个自定义适配器。我想为此设置一些文本颜色(例如橙色代码#F06D2F)。我正在展示我的代码片段getView()
method.
TextView text = new TextView(this.context);
// text.setPadding(25, 5, 0, 0);
text.setBackgroundResource(R.drawable.back_horizontal);
// text.setClickable(false);
// text.setFocusable(false);
text.setEllipsize(TruncateAt.END);
text.setSingleLine(true);
// text.setTextColor(R.color.yellow);
text.setTextColor(R.color.Orange);
text.setGravity(Gravity.CENTER_VERTICAL);
helvetica_normal = Typeface.createFromAsset(context.getAssets(), "fonts/helvetica.ttf");
text.setTypeface(helvetica_normal);
// text.setTextColor(R.color.yellow);
text.setText(objects[position]);
LayoutParams layoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
manager.addView(text, layoutParams);
问题是我看不到颜色设置为橙色。什么地方出了错?
Note:上下文在构造函数和对象(字符串数组)中传递
感谢您的帮助
尝试这样,以下对我来说效果很好
textview.setTextColor(this.getResources().getColor(R.color.orange));
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)