Get value from Resource - Android App

Android examples for App:Resource

Description

Get value from Resource

Demo Code


//package com.java2s;

import android.content.Context;

import android.util.TypedValue;

public class Main {
    private static TypedValue mTmpValue = new TypedValue();

    public static int getResourceValue(Context context, int resId) {
        TypedValue value = mTmpValue;//  w  ww .j a va  2 s  .  com
        context.getResources().getValue(resId, value, true);
        return (int) TypedValue.complexToFloat(value.data);
    }
}

Related Tutorials