Android examples for App:Resource
get Dimens Resource
//package com.java2s; import android.content.Context; public class Main { public static int getDimensResource(Context ctx, String name) { String packageName = ctx.getPackageName(); try {// ww w .j a va 2 s. c o m Object obj; obj = Class.forName(packageName + ".R$dimen").newInstance(); return Class.forName(packageName + ".R$dimen") .getDeclaredField(name).getInt(obj); } catch (Exception e) { e.printStackTrace(); return 0; } } }