find View By Id via Activity - Android User Interface

Android examples for User Interface:View Find

Description

find View By Id via Activity

Demo Code


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

public class Main {
    @SuppressWarnings({ "unchecked", "UnusedDeclaration" })
    public static <T extends View> T findViewById(View view, int id) {
        return (T) view.findViewById(id);
    }//from  w ww  . jav a2 s  . c om

    @SuppressWarnings({ "unchecked", "UnusedDeclaration" })
    public static <T extends View> T findViewById(Activity activity, int id) {
        return (T) activity.findViewById(id);
    }
}

Related Tutorials