protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); adapter = new TabsAdapter(this, SupportFragmentManager); pager = FindViewById <ViewPager>(Resource.Id.viewpager); var tabs = FindViewById <TabLayout>(Resource.Id.tabs); pager.Adapter = adapter; tabs.SetupWithViewPager(pager); pager.OffscreenPageLimit = 3; pager.PageSelected += (sender, args) => { var fragment = adapter.InstantiateItem(pager, args.Position) as IFragmentVisible; fragment?.BecameVisibleAsync(); }; // add event handler for menu item clickS. For now to select target language Toolbar.MenuItemClick += Toolbar_MenuItemClick; SupportActionBar.SetDisplayHomeAsUpEnabled(false); SupportActionBar.SetHomeButtonEnabled(false); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); adapter = new TabsAdapter(this, SupportFragmentManager); pager = FindViewById <ViewPager>(Resource.Id.viewpager); var tabs = FindViewById <TabLayout>(Resource.Id.tabs); pager.Adapter = adapter; tabs.SetupWithViewPager(pager); pager.OffscreenPageLimit = 3; pager.PageSelected += (sender, args) => { var fragment = adapter.InstantiateItem(pager, args.Position) as IFragmentVisible; fragment?.BecameVisible(); }; Toolbar.MenuItemClick += (sender, e) => { var intent = new Intent(this, typeof(AddItemActivity));; StartActivity(intent); }; SupportActionBar.SetDisplayHomeAsUpEnabled(false); SupportActionBar.SetHomeButtonEnabled(false); CreateNotificationChannel(); var button = FindViewById <Button>(Resource.Id.MyButton); button.Click += ButtonOnClick; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); var data = Intent.GetStringExtra("data"); appPreferences = new AppPreferences(Application.Context); var item = Newtonsoft.Json.JsonConvert.DeserializeObject <Facility>(data); viewModel = new FacilityDetailViewModel(item); Bundle mybundle = new Bundle(); mybundle.PutString("data", Newtonsoft.Json.JsonConvert.SerializeObject(item)); adapter = new TabsAdapter(this, SupportFragmentManager, mybundle); pager = FindViewById <ViewPager>(Resource.Id.viewpager); var tabs = FindViewById <TabLayout>(Resource.Id.tabs); pager.Adapter = adapter; tabs.SetupWithViewPager(pager); pager.OffscreenPageLimit = 3; Toolbar.MenuItemClick += (sender, e) => { var itemTitle = e.Item.TitleFormatted; switch (itemTitle.ToString()) { case "Log Out": var intent = new Intent(this, typeof(LoginActivity)); appPreferences.SaveUserId("0"); StartActivity(intent); break; case "Submit": FacilityInformationFragment fragment = (FacilityInformationFragment)SupportFragmentManager.Fragments[1]; if (fragment != null) { fragment.SubmitFacility(); } break; case "Add": var buildingIntent = new Intent(this, typeof(AddBuildingActivity));; StartActivity(buildingIntent); break; } }; pager.PageSelected += (sender, args) => { var fragment = adapter.InstantiateItem(pager, args.Position) as IFragmentVisible; fragment?.BecameVisible(); }; SupportActionBar.Title = item.Name; SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); var data = Intent.GetStringExtra("data"); var item = Newtonsoft.Json.JsonConvert.DeserializeObject <Facility>(data); viewModel = new FacilityDetailViewModel(item); Bundle mybundle = new Bundle(); mybundle.PutString("data", Newtonsoft.Json.JsonConvert.SerializeObject(item)); adapter = new TabsAdapter(this, SupportFragmentManager, mybundle); pager = FindViewById <ViewPager>(Resource.Id.viewpager); var tabs = FindViewById <TabLayout>(Resource.Id.tabs); pager.Adapter = adapter; tabs.SetupWithViewPager(pager); pager.OffscreenPageLimit = 3; Toolbar.MenuItemClick += (sender, e) => { var intent = new Intent(this, typeof(LoginActivity));; StartActivity(intent); }; pager.PageSelected += (sender, args) => { var fragment = adapter.InstantiateItem(pager, args.Position) as IFragmentVisible; fragment?.BecameVisible(); }; SupportActionBar.Title = item.Name; SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); }