Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import android.content.Context;
import android.content.res.Resources;

import android.util.TypedValue;

public class Main {
    /**
     * Returns an int array with the color values for the given attributes (R.attr).
     * Any unresolved colors will be represented by -1
     */
    public static int[] getThemeColorIDs(final Context context, final int[] attrs) {
        int[] colors = new int[attrs.length];
        Resources.Theme theme = context.getTheme();
        for (int i = 0; i < attrs.length; i++) {
            TypedValue typedValue = new TypedValue();
            if (theme.resolveAttribute(attrs[i], typedValue, true)) {
                colors[i] = typedValue.data;
            } else {
                colors[i] = -1;
            }
        }
        return colors;
    }
}