Android examples for App:R
get Int In Class R using reflection
//package com.java2s; import java.lang.reflect.Field; import android.content.Context; import android.content.res.Resources.NotFoundException; public class Main { public static int getIntInClassR(Context context, Class<?> classR, String filedName) {/*from w w w . ja v a 2 s . c om*/ if (classR != null) { try { Field intField = classR.getField(filedName); int sourceId = intField.getInt(intField); return sourceId; } catch (NoSuchFieldException e) { } catch (IllegalAccessException e) { } catch (IllegalArgumentException e) { } catch (NotFoundException e) { } } return -1; } }