Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/**
 * (c) Winterwell Associates Ltd, used under MIT License. This file is background IP.
 */

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

public class Main {
    public static <X extends View> X getChild(ViewGroup row, Class<X> klass) {
        assert klass != null;
        for (int i = 0; i < row.getChildCount(); i++) {
            View child = row.getChildAt(i);
            if (klass.isAssignableFrom(child.getClass())) {
                return klass.cast(child);
            }

            if (child instanceof ViewGroup) {
                X kid = getChild((ViewGroup) child, klass);
                if (kid != null)
                    return kid;
            }
        }
        // fail
        return null;
    }
}