@ SuppressWarnings ( "unchecked" ) // we know that return value type is a child of view, and V is bound to a child of view. public static < V extends View > V findViewById ( Activity activity , int id ) { return ( V ) activity . findViewById ( id ) ; }
Find the specific view from the activity . Returning value type is bound to your variable type .