@ SuppressWarnings ( "unchecked" ) protected final < ViewType extends View > ViewType findViewById ( @ IdRes final int viewId ) { Condition . INSTANCE . ensureNotNull ( currentParentView , "No parent view set" , IllegalStateException . class ) ; ViewHolder viewHolder = ( ViewHolder ) currentParentView . getTag ( ) ; if ( viewHolder == null ) { viewHolder = new ViewHolder ( currentParentView ) ; currentParentView . setTag ( viewHolder ) ; } return ( ViewType ) viewHolder . findViewById ( viewId ) ; }
References the view which belongs to a specific resource ID by using the view holder pattern . The view is implicitly casted to the type of the field it is assigned to .