Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Context;
import java.lang.reflect.Field;

public class Main {
    /*********************************************************************************
     * Returns the resource-IDs for all attributes specified in the given
     * <declare-styleable>-resource tag as an int array.
     *
     * @param context
     *            The current application context.
     * @param name
     *            The name of the <declare-styleable>-resource-tag to pick.
     * @return All resource-IDs of the child-attributes for the given
     *         <declare-styleable>-resource or <code>null</code> if this tag
     *         could not be found or an error occured.
     *********************************************************************************/
    public static final int[] getResourceDeclareStyleableIntArray(Context context, String name) {
        try {
            Field[] fields2 = Class.forName(context.getPackageName() + ".R$styleable").getFields();
            for (Field f : fields2) {
                if (f.getName().equals(name)) {
                    int[] ret = (int[]) f.get(null);
                    return ret;
                }
            }
        } catch (Throwable t) {
        }

        return null;
    }
}