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,901
  • 21
  • 84
  • 115
Francis Ting
  • 671
  • 6
  • 15

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
  • 713
  • 5
  • 13