Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            var weatherService = new WeatherService();
            // string response = weatherService.Get3DayForecast("Eugene", "OR", ForecastFormat.xml);
            // var forecasts = weatherService.ParseForecastXML(response);
            string response  = weatherService.Get3DayForecast("Eugene", "OR", ForecastFormat.json);
            var    forecasts = weatherService.ParseForecastJson(response);

            foreach (ShortForecast f in forecasts)
            {
                Console.WriteLine(f.Title);
                Console.WriteLine(f.ForecastText);
                Console.WriteLine("--------------------------------------");
            }
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Main);

            var wuTextView = FindViewById <TextView>(Resource.Id.wuTextView);

            wuTextView.TextFormatted = Html.FromHtml(
                "<a href=\"https://www.wunderground.com/?apiref=5cdccc9428586099\">Data from Weather Underground</a> ");
            wuTextView.MovementMethod = LinkMovementMethod.Instance;

            WeatherService weatherService = new WeatherService();
            // string response = weatherService.Get3DayForecast("Eugene", "OR", ForecastFormat.xml);
            // var forecasts = weatherService.ParseForecastXML(response);
            string response  = weatherService.Get3DayForecast("Eugene", "OR", ForecastFormat.json);
            var    forecasts = weatherService.ParseForecastJson(response);

            var forecastListView = FindViewById <ListView>(Resource.Id.forecastListView);

            forecastListView.Adapter = new ArrayAdapter <ShortForecast>(this,
                                                                        Android.Resource.Layout.SimpleListItem1,
                                                                        forecasts);
        }