Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.graphics.Typeface;

import android.view.View;
import android.view.ViewGroup;
import android.widget.*;

public class Main {
    public static Typeface regularFont, boldFont;

    public static void setFontAllView(ViewGroup vg) {
        for (int i = 0; i < vg.getChildCount(); ++i) {
            View child = vg.getChildAt(i);

            if (child instanceof ViewGroup) {
                setFontAllView((ViewGroup) child);
            } else if (child != null) {
                Typeface face;
                if (child.getTag() != null && child.getTag().toString().toLowerCase().equals("bold")) {
                    face = boldFont;
                } else {
                    face = regularFont;
                }

                if (child instanceof TextView) {
                    TextView textView = (TextView) child;
                    textView.setTypeface(face);
                } else if (child instanceof EditText) {
                    EditText editView = (EditText) child;
                    editView.setTypeface(face);
                } else if (child instanceof RadioButton) {
                    RadioButton radioView = (RadioButton) child;
                    radioView.setTypeface(face);
                } else if (child instanceof CheckBox) {
                    CheckBox checkboxView = (CheckBox) child;
                    checkboxView.setTypeface(face);
                } else if (child instanceof Button) {
                    Button button = (Button) child;
                    button.setTypeface(face);
                }
            }
        }
    }
}