Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: LGPL 

import android.graphics.Color;

public class Main {
    public static String toColorString(int bgColor) {
        return "#" + hex2(Color.alpha(bgColor)) + hex2(Color.red(bgColor)) + hex2(Color.green(bgColor))
                + hex2(Color.blue(bgColor));
    }

    public static String hex2(int val) {
        String a = Integer.toHexString(val);
        if (a.length() < 2) {
            a = "0" + a;
        }
        return a;
    }
}