Reputation: 791
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) {
}
}
Upvotes: 1
Views: 92
Reputation: 723
Activity is Context, so you can use "this" for the first parameter. findViewById(android.R.id.content) will be the second one.
Upvotes: 1