topical media & game development

talk show tell print

#mobile-application-12-DerbyNames-MonoAndroid-DerbyNames-MonoAndroid-LeagueTab.cs / cs



  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  
  using Android.App;
  using Android.Content;
  using Android.OS;
  using Android.Runtime;
  using Android.Views;
  using Android.Widget;
  
  namespace DerbyNames_MonoAndroid
  {
          public class LeaugeTab: Fragment
      {            
          public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
          {
              base.OnCreateView (inflater, container, savedInstanceState);
              
              var view = inflater.Inflate (Resource.Layout.tab, container, false);
              var derbyData = view.FindViewById<ListView> (Resource.Id.DerbyData);             
                  
                          
                          List<League> fullLeagueData = Network.GetLeaugeData();
                          List<string> data = new List<string>();
                          fullLeagueData.ForEach(league => data.Add(league.LeagueName));
                                                 
                          derbyData.Adapter = new ArrayAdapter<string> (container.Context, Resource.Layout.list_item, data.ToArray());
                  
                          derbyData.ItemClick += delegate (object sender, ItemEventArgs args) {
                                  string teamName = ((TextView)args.View).Text;
                                  Intent rosterList = new Intent(container.Context, typeof(LeagueRoster));
                                  
                                  rosterList.PutExtra("TeamName", teamName);
                                  this.StartActivity(rosterList);
                          };
                          
              return view;
          }
          }
  }
  
  


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.