{"comment":{"url":"https://api.github.com/repos/lvliheng/GetColorByRGB/comments/9968500","html_url":"https://github.com/lvliheng/GetColorByRGB/commit/0b4cc373b95e3ea25ac5515436fdc3a7e1f1a39d#commitcomment-9968500","id":9968500,"user":{"login":"lvliheng","id":8185812,"avatar_url":"https://avatars.githubusercontent.com/u/8185812?v=3","gravatar_id":"","url":"https://api.github.com/users/lvliheng","html_url":"https://github.com/lvliheng","followers_url":"https://api.github.com/users/lvliheng/followers","following_url":"https://api.github.com/users/lvliheng/following{/other_user}","gists_url":"https://api.github.com/users/lvliheng/gists{/gist_id}","starred_url":"https://api.github.com/users/lvliheng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lvliheng/subscriptions","organizations_url":"https://api.github.com/users/lvliheng/orgs","repos_url":"https://api.github.com/users/lvliheng/repos","events_url":"https://api.github.com/users/lvliheng/events{/privacy}","received_events_url":"https://api.github.com/users/lvliheng/received_events","type":"User","site_admin":false},"position":2,"line":2,"path":"README.md","commit_id":"0b4cc373b95e3ea25ac5515436fdc3a7e1f1a39d","created_at":"2015-02-28T03:27:29Z","updated_at":"2015-02-28T03:27:29Z","body":"之前自己写的：\r\n\r\nprivate String tenToSixteen(EditText et) {\r\nif(\"\".equals(et.getText().toString().trim())){\r\net.startAnimation(mAnimation);\r\nreturn \"error\";\r\n}\r\nint value=Integer.parseInt(et.getText().toString().trim());\r\nString result = \"\";\r\nif(value255){\r\net.startAnimation(mAnimation);\r\nreturn \"error\";\r\n}else{\r\nif(value==0){\r\nreturn \"00\";\r\n}else{\r\nint first = value / 16;\r\nint last = 0;\r\nif (first == 0) {// value if (value > 0 && value < 10) {\r\nresult = \"0\"+value;\r\n} else if (value > 9) {\r\nresult = \"0\"+numToLetter(value);\r\n}\r\n} else {// value>=16\r\nlast = value - first * 16;\r\nif(last==0){// value=16n\r\nif (first > 0 && first < 10) {\r\nresult = first+\"0\";\r\n} else if (first > 9) {\r\nresult = numToLetter(first)+\"0\";\r\n}\r\nreturn result;\r\n}else{\r\nif (first > 0 && first < 10) {\r\nif (last > 0 && last < 10) {\r\nresult = first +\"\"+ last;\r\n} else if (last > 9) {\r\nresult = first + numToLetter(last);\r\n}\r\n} else if (first > 9) {\r\nif (last > 0 && last < 10) {\r\nresult = numToLetter(first) + \"\" + last;\r\n} else if (last > 9) {\r\nresult = numToLetter(first) + numToLetter(last);\r\n}\r\n}\r\n}\r\n}\r\n\r\n}\r\n}\r\nreturn result;\r\n}\r\n\r\nprivate String numToLetter(int num) {\r\n    return String.valueOf((char) ('a' + (num - 10)));\r\n}\r\n后来看到人家的代码，才发现不用这么麻烦：\r\n\r\nString resultStr = String.format(\"#%02x%02x%02x\", mList.get(0).getProgress(), mList.get(1).getProgress(), mList.get(2).getProgress());\r\n![2015-02-27 5 44 23](https://cloud.githubusercontent.com/assets/8185812/6424643/b7da3b8c-bf3c-11e4-8fb1-76c54c245868.png)\r\n![2015-02-27 5 38 00](https://cloud.githubusercontent.com/assets/8185812/6424645/c28f74b6-bf3c-11e4-92d2-b6f4bd68989f.png)\r\n\r\n"}}