Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.content.Context;

import android.content.res.TypedArray;
import android.util.TypedValue;

public class Main {
    public static int getColorFromContext(Context context, int color_id) {
        int[] textSizeAttr = new int[] { color_id };
        TypedValue typedValue = new TypedValue();
        TypedArray a = context.obtainStyledAttributes(typedValue.data, textSizeAttr);
        int color = a.getColor(0, 0);
        a.recycle();
        return color;
    }
}