Set Font To Controls via ViewGroup - Android User Interface

Android examples for User Interface:ViewGroup

Description

Set Font To Controls via ViewGroup

Demo Code


//package com.java2s;

import android.graphics.Typeface;

import android.view.View;
import android.view.ViewGroup;

import android.widget.TextView;

public class Main {
    public static void SetFontToControls(Typeface font, ViewGroup vg) {
        for (int i = 0; i < vg.getChildCount(); i++) {
            View child = vg.getChildAt(i);
            if (child instanceof TextView)
                ((TextView) child).setTypeface(font);
            if (child instanceof ViewGroup) {
                SetFontToControls(font, (ViewGroup) child);
            }/*from  w ww.  ja v  a 2s .  com*/
        }
    }
}

Related Tutorials