コード例 #1
0
        private void updateWeatherData(string cityname)
        {
            this.input_cityname.Text = cityname;
            weather = new JsonFile(this.input_cityname.Text);

            Lab_city.Text = "city: " + weather.cityname;
            Lab_date.Text = "date: " + weather.data["0"]["date"];
            Lab_time.Text = "time: " + weather.data["0"]["time"];
            Lab_MaxTemperature.Text = "maxTemperature: " + weather.data["0"]["maxTemperature"];
            Lab_MinTemperature.Text = "minTemperature: " + weather.data["0"]["minTemperature"];

            Console.WriteLine("Response 11111");
        }
コード例 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            //get Data
            //    得到跳转到该Activity的Intent对象
            Bundle bundle = Intent.GetBundleExtra("bundle");
            string index = bundle.GetString("index");
            //string SelectCity = bundle.GetString("SelectCity");
            string SelectCity = bundle.GetString("Taiwan");

            JsonFile Jsondata = new JsonFile(SelectCity);

            // Create your application here
            SetContentView(Resource.Layout.Detail);
            ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;

            var pager = FindViewById<ViewPager>(Resource.Id.pager);
            var adaptor = new GenericFragmentPagerAdaptor(SupportFragmentManager);

            adaptor.AddFragmentView((i, v, b) =>
            {
                var view = i.Inflate(Resource.Layout.tab, v, false);
                var sampleTextView = view.FindViewById<TextView>(Resource.Id.textView1);
                sampleTextView.Text = "日期: " + Jsondata.data[(Convert.ToInt32(index) + 2).ToString()]["date"] + "\n" +
                                      "時間: " + Jsondata.data[(Convert.ToInt32(index) + 2).ToString()]["time"] + "\n" +
                                      "最高溫: " + Jsondata.data[(Convert.ToInt32(index) + 2).ToString()]["maxTemperature"] + "\n" +
                                      "最低溫: " + Jsondata.data[(Convert.ToInt32(index) + 2).ToString()]["minTemperature"] + "\n" +
                                      "humidity: " + Jsondata.data[(Convert.ToInt32(index) + 2).ToString()]["humidity"] + "\n" +
                                      "chanceOfClouds: " + Jsondata.data[(Convert.ToInt32(index) + 2).ToString()]["chanceOfClouds"] + "\n" +
                                      "降雨量: " + Jsondata.data[(Convert.ToInt32(index) + 2).ToString()]["volumeOfRain"] + "\n" +
                                      "氣候: " + Jsondata.data[(Convert.ToInt32(index) + 2).ToString()]["description"] + "\n" ;

                return view;
            }
            );

            adaptor.AddFragmentView((i, v, b) =>
            {
                var view = i.Inflate(Resource.Layout.tab, v, false);
                var sampleTextView = view.FindViewById<TextView>(Resource.Id.textView1);
                sampleTextView.Text = "日期: " + Jsondata.data[(Convert.ToInt32(index) + 4).ToString()]["date"] + "\n" +
                                      "時間: " + Jsondata.data[(Convert.ToInt32(index) + 4).ToString()]["time"] + "\n" +
                                      "最高溫: " + Jsondata.data[(Convert.ToInt32(index) + 4).ToString()]["maxTemperature"] + "\n" +
                                      "最低溫: " + Jsondata.data[(Convert.ToInt32(index) + 4).ToString()]["minTemperature"] + "\n" +
                                      "humidity: " + Jsondata.data[(Convert.ToInt32(index) + 4).ToString()]["humidity"] + "\n" +
                                      "chanceOfClouds: " + Jsondata.data[(Convert.ToInt32(index) + 4).ToString()]["chanceOfClouds"] + "\n" +
                                      "降雨量: " + Jsondata.data[(Convert.ToInt32(index) + 4).ToString()]["volumeOfRain"] + "\n" +
                                      "氣候: " + Jsondata.data[(Convert.ToInt32(index) + 4).ToString()]["description"] + "\n";
                return view;
            }
            );

            adaptor.AddFragmentView((i, v, b) =>
            {
                var view = i.Inflate(Resource.Layout.tab, v, false);
                var sampleTextView = view.FindViewById<TextView>(Resource.Id.textView1);
                sampleTextView.Text = "日期: " + Jsondata.data[(Convert.ToInt32(index) + 6).ToString()]["date"] + "\n" +
                                      "時間: " + Jsondata.data[(Convert.ToInt32(index) + 6).ToString()]["time"] + "\n" +
                                      "最高溫: " + Jsondata.data[(Convert.ToInt32(index) + 6).ToString()]["maxTemperature"] + "\n" +
                                      "最低溫: " + Jsondata.data[(Convert.ToInt32(index) + 6).ToString()]["minTemperature"] + "\n" +
                                      "humidity: " + Jsondata.data[(Convert.ToInt32(index) + 6).ToString()]["humidity"] + "\n" +
                                      "chanceOfClouds: " + Jsondata.data[(Convert.ToInt32(index) + 6).ToString()]["chanceOfClouds"] + "\n" +
                                      "降雨量: " + Jsondata.data[(Convert.ToInt32(index) + 6).ToString()]["volumeOfRain"] + "\n" +
                                      "氣候: " + Jsondata.data[(Convert.ToInt32(index) + 6).ToString()]["description"] + "\n";
                return view;
            }
            );

            pager.Adapter = adaptor;
            //pager.SetOnPageChangeListener(new ViewPageListenerForActionBar(ActionBar));
            pager.AddOnPageChangeListener(new ViewPageListenerForActionBar(ActionBar));

            ActionBar.AddTab(pager.GetViewPageTab(ActionBar, "早上"));
            ActionBar.AddTab(pager.GetViewPageTab(ActionBar, "中午"));
            ActionBar.AddTab(pager.GetViewPageTab(ActionBar, "晚上"));
        }
コード例 #3
0
        private void updateWeatherdData(string index)
        {
            TextView Lab_SelectCity = FindViewById<TextView>(Resource.Id.Lab_SelectCity);
            TextView Lab_CityName = FindViewById<TextView>(Resource.Id.Lab_CityName);
            TextView Lab_maxTempreature = FindViewById<TextView>(Resource.Id.Lab_maxTemperature);
            TextView Lab_minTemperature = FindViewById<TextView>(Resource.Id.Lab_minTemperature);
            TextView Lab_Datetime = FindViewById<TextView>(Resource.Id.Lab_Datetime);
            TextView Lab_description = FindViewById<TextView>(Resource.Id.Lab_description);

            Jsondata = new JsonFile(Lab_SelectCity.Text);
            Lab_CityName.Text = Jsondata.cityname;
            Lab_maxTempreature.Text = Jsondata.data[index]["maxTemperature"].ToString();
            Lab_minTemperature.Text = Jsondata.data[index]["minTemperature"].ToString();
            Lab_Datetime.Text = Jsondata.data[index]["date"]+"\n"+ Jsondata.data[index]["time"];
            Lab_description.Text = Jsondata.data[index]["description"].ToString();

            if (Jsondata.data[(Convert.ToInt32(index) + 8).ToString()]==null)
            {
                Button Btu_NextDay = FindViewById<Button>(Resource.Id.NextDay);
                Btu_NextDay.Enabled = false;
                Console.Write("updateWeatherdData null");
            }
        }