最近遇到后台传递颜色字符串,然后根据传递的字符串颜色改变TextView的背景颜色的问题。
解决方案:
TextView mTextView= (TextView) view.findViewById(R.id.item_index_three_shuxian);
mTextView.setBackgroundColor(StringtoColor("0000ff"));
private int StringtoColor(String str) {
return 0xff000000 | Integer.parseInt(str.substring(1), 16);
}
这样Textview的背景颜色就是“0000ff”;
第一次写博客,这个问题解决方案可能有很多,请大神不吝赐教。