Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.util.TypedValue; public class Main { /** * Last but not least, try to pull the Font Path from the Theme, which is defined. * * @param context Activity Context * @param styleId Theme style id * @param attributeId if -1 returns null. * @return null if no theme or attribute defined. */ static String pullFontPathFromTheme(Context context, int styleId, int attributeId) { if (styleId == -1 || attributeId == -1) return null; final Resources.Theme theme = context.getTheme(); final TypedValue value = new TypedValue(); theme.resolveAttribute(styleId, value, true); final TypedArray typedArray = theme.obtainStyledAttributes(value.resourceId, new int[] { attributeId }); try { return typedArray.getString(0); } catch (Exception ignore) { // Failed for some reason. return null; } finally { typedArray.recycle(); } } }