List of usage examples for android.content Context getResources
public abstract Resources getResources();
From source file:Main.java
public static int getStyleId(Context paramContext, String paramString) { return paramContext.getResources().getIdentifier(paramString, "style", paramContext.getPackageName()); }
From source file:Main.java
public static boolean isTablet(Context context) { int screenLayoutMask = context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; return (screenLayoutMask == 4)// Configuration.SCREENLAYOUT_SIZE_XLARGE = 4 || (screenLayoutMask == Configuration.SCREENLAYOUT_SIZE_LARGE); }
From source file:Main.java
public static int getId(Context paramContext, String paramString) { return paramContext.getResources().getIdentifier(paramString, "id", paramContext.getPackageName()); }
From source file:Main.java
public static int getAnimId(Context paramContext, String paramString) { return paramContext.getResources().getIdentifier(paramString, "anim", paramContext.getPackageName()); }
From source file:Main.java
public static int dip2Px(Context context, float dpValue) { float scale = context.getResources().getDisplayMetrics().density; return (int) (dpValue * scale + 0.5f); }
From source file:Main.java
public static int getScreenWidth(Context context) { DisplayMetrics dm = context.getResources().getDisplayMetrics(); return dm.widthPixels; }
From source file:Main.java
public static int getStringArrayId(Context paramContext, String paramString) { return paramContext.getResources().getIdentifier(paramString, "array", paramContext.getPackageName()); }
From source file:Main.java
public static int convertDpToPixel(float dp, Context context) { Resources resources = context.getResources(); DisplayMetrics metrics = resources.getDisplayMetrics(); int px = (int) (dp * ((float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT)); return px;//from w w w.j a va2 s . co m }
From source file:Main.java
public static void setViewTag(View v, Context context, int sourceId) { v.setTag(context.getResources().getStringArray(sourceId)); }
From source file:Main.java
public static int convertDpToPx(Context context, int dp) { final float density = context.getResources().getDisplayMetrics().density; return (int) Math.ceil(dp * density); }