Android 改变孩子';s可扩展列表的文本颜色
我已经回顾了以前的问题,并尝试了提供的所有解决方案,但似乎没有任何效果,我有一个可扩展的列表,我想将子元素的文本颜色设置为白色(非透明,纯白色),这是我的代码:Android 改变孩子';s可扩展列表的文本颜色,android,eclipse,colors,Android,Eclipse,Colors,我已经回顾了以前的问题,并尝试了提供的所有解决方案,但似乎没有任何效果,我有一个可扩展的列表,我想将子元素的文本颜色设置为白色(非透明,纯白色),这是我的代码: public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { TextView textView
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
TextView textView = getGenericView();
textView.setText(getChild(groupPosition, childPosition).toString());
textView.setTextColor(color.white);
return textView;
}
我还尝试:
textView.setTextColor(getResources().getColor(R.color.white))代码>
但是当我运行应用程序时,文本永远不会显示(我不确定它是否使其透明)
我该怎么办?如果您担心它是透明的,请传递一个对应于不透明白色的<0xffffff
十六进制值,而不是颜色。白色您可以使用十六进制值
textView.setTextColor(Color.parseColor("#FFFFFF"));
我使用了parseColor方法,该方法将十六进制转换为有效的颜色
颜色是一个类。使用
textView.setTextColor(Color.white);
而不是
textView.setTextColor(color.white);
欢迎来到SO!这将有助于您发布链接到您在文章中提到的解决方案。