protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it SetContentView(Resource.Layout.Main); 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 = "This is content"; 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 = "This is more content"; return(view); } ); pager.Adapter = adaptor; //pager.SetOnPageChangeListener(new ViewPageListenerForActionBar(ActionBar)); pager.AddOnPageChangeListener(new ViewPageListenerForActionBar(ActionBar)); ActionBar.AddTab(pager.GetViewPageTab(ActionBar, "Tab1")); ActionBar.AddTab(pager.GetViewPageTab(ActionBar, "Tab2")); ActionBar.AddTab(pager.GetViewPageTab(ActionBar, "Tab3")); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it SetContentView(Resource.Layout.Main); 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 = "This is content"; 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 = "This is more content"; return view; } ); pager.Adapter = adaptor; //pager.SetOnPageChangeListener(new ViewPageListenerForActionBar(ActionBar)); pager.AddOnPageChangeListener(new ViewPageListenerForActionBar(ActionBar)); ActionBar.AddTab(pager.GetViewPageTab(ActionBar, "Tab1")); ActionBar.AddTab(pager.GetViewPageTab(ActionBar, "Tab2")); ActionBar.AddTab(pager.GetViewPageTab(ActionBar, "Tab3")); }
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, "晚上")); }