void InitializeView() { var linearLayout = new LinearLayout(this); linearLayout.LayoutParameters = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent ); linearLayout.Orientation = Orientation.Vertical; _toolbar = new Toolbar(this); _toolbar.Title = "Weather"; _toolbar.SetTitleTextColor(Android.Graphics.Color.DodgerBlue); _toolbar.SetBackgroundColor(Android.Graphics.Color.WhiteSmoke); _toolbar.LayoutParameters = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent ); linearLayout.AddView(_toolbar); SetSupportActionBar(_toolbar); SupportActionBar.SetDisplayShowTitleEnabled(true); var frameLayout = new FrameLayout(this); frameLayout.LayoutParameters = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent ); frameLayout.Id = new Random().Next(int.MaxValue); linearLayout.AddView(frameLayout); _listPage = new WeatherListPage(); _listPageFragment = _listPage.CreateSupportFragment(this); var ft = SupportFragmentManager.BeginTransaction(); ft.AddToBackStack(null); ft.Replace(frameLayout.Id, _listPageFragment); ft.Commit(); SetContentView(linearLayout); }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { var p = SQLite.SQLiteException.New(SQLite.SQLite3.Result.Row, ""); global::Xamarin.Forms.Forms.Init(); Bootstrap.Begin( () => new LocationService(), () => new AlertService(), () => FileSystem.RegisterService(new FileSystemService()), false ); Window = new UIWindow(UIScreen.MainScreen.Bounds); var listPage = new WeatherListPage(); listPage.WeatherSelected += OnWeatherSelected; var listViewController = listPage.CreateViewController(); listViewController.NavigationItem.SetRightBarButtonItem( new UIBarButtonItem( "Add", UIBarButtonItemStyle.Plain, (sender, args) => { listPage.ViewModel.AddFavoriteCommand.Execute(null); }), true); _navigation = new UINavigationController(listViewController); Window.RootViewController = _navigation; Window.MakeKeyAndVisible(); return(true); }