Java tutorial
//package com.java2s; //License from project: Open Source License import android.app.Activity; import android.view.View; public class Main { public static <T extends View> T lfind(Activity aty, int id, Class<T> clazz) { View view = aty.findViewById(id); return clazz.cast(view); } }