我正在制作一个应用程序,我希望能够通过用户输入(edittext)和十六进制值(例如#eeeeee等)设置各种颜色。问题是我似乎无法弄清楚如何转换它们。
如果我在这样的代码中执行某项操作,它将正常工作:titlebar.setBackgroundColor(0xFF545455);
但是,如果我通过edittext检索到一个值,说“ 545455”,则无法正常工作
String tbColor = tb_color.getText().toString();
String value = "0xFF" + tbColor;
int setColor = Integer.valueOf(value);
titlebar.setBackgroundColor(setColor);
有人对如何实现此目标有任何想法吗?
例如:
titlebar.setBackgroundColor(Integer.parseInt("545455", 16)+0xFF000000);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句