1

I have this piece of code that I copied from set-font-for-all-textviews-in-activity. My problem is how to call this method from onCreate?

Trying overrideFonts();

Code:

public void overrideFonts(final Context context, final View v) {
    try {
        if (v instanceof ViewGroup) {
            ViewGroup vg = (ViewGroup) v;
            for (int i = 0; i < vg.getChildCount(); i++) {
                View child = vg.getChildAt(i);
                overrideFonts(context, child);
            }
        } else if (v instanceof TextView ) {
            ((TextView) v).setTypeface(Typeface.createFromAsset(context.getAssets(), "fonts/Raleway-Light.ttf"));
        }
    } catch (Exception e) {
    }
}
Phantômaxx
  • 37,352
  • 21
  • 80
  • 110
Francis Ting
  • 531
  • 4
  • 14

1 Answers1

1

Activity is Context, so you can use "this" for the first parameter. findViewById(android.R.id.content) will be the second one.

Grisha
  • 703
  • 4
  • 13