find View For Activity - Android User Interface

Android examples for User Interface:View Find

Description

find View For Activity

Demo Code


//package com.java2s;
import android.app.Activity;
import android.view.View;

public class Main {
    @SuppressWarnings("unchecked")
    public static <ViewType extends View> ViewType findFor(
            Activity activity, int id) {
        return (ViewType) activity.findViewById(id);
    }//from  w w w  . j  a v  a 2 s  . c  o m

    @SuppressWarnings("unchecked")
    public static <ViewType extends View> ViewType findFor(View view, int id) {
        return (ViewType) view.findViewById(id);
    }
}

Related Tutorials