private void renderEpisodesHeader ( TvShowViewModel tvShow ) { episodesListView . removeHeaderView ( header ) ; header = ( TextView ) getLayoutInflater ( ) . inflate ( R . layout . episode_header , null ) ; header . setText ( tvShow . getTitle ( ) . toUpperCase ( ) + " - SEASON 1" ) ; episodesListView . setAdapter ( null ) ; episodesListView . addHeaderView ( header ) ; episodesListView . setOnItemClickListener ( new AdapterView . OnItemClickListener ( ) { @ Override public void onItemClick ( AdapterView < ? > adapterView , View view , int position , long id ) { if ( tvShowSelected != null ) { if ( position > 0 ) { EpisodeViewModel episodeViewModel = tvShowSelected . getEpisodes ( ) . get ( position - 1 ) ; Toast . makeText ( getBaseContext ( ) , tvShowSelected . getTitle ( ) + " - " + episodeViewModel . getTitle ( ) , Toast . LENGTH_LONG ) . show ( ) ; } } } } ) ; }
Configure a view as episodes ListView header with the name of the tv show and the season .