我想知道如何完成转换:
我已经检查了以下说明:
int color= ((ColorDrawable) dialog1.getButton(AlertDialog.BUTTON_POSITIVE).getBackground()).getColor();
在某些设备中给出结果color = -12434878,检查该颜色是否等于HTML颜色#424242。
但是,关键是我看不到从一种转换到另一种的方法,也没有找到任何对此的参考。
这怎么办?
答案 0 :(得分:1)
将整数转换为十六进制字符串
Integer intColor = -12434878;
String hexColor = "#" + Integer.toHexString(intColor).substring(2);