protected async override void OnCreate(Bundle bundle) { base.OnCreate(bundle); Forms.Init(this, bundle); UserName = Intent.GetStringExtra("USERNAME"); UserPassword = Intent.GetStringExtra("PASSWORD"); // Deactivated local User Database // UserId = Intent.GetIntExtra("USERID", -1); #region Connect to OPC UA Server // when View is created: connect the client to the specified Endpoint Connect(); #endregion // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Find views _pager = FindViewById <ViewPager>(Resource.Id.pager); _tabLayout = FindViewById <TabLayout>(Resource.Id.sliding_tabs); var adapter = new MenuPagerAdapter(this, SupportFragmentManager); _toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); //Setup Toolbar SetSupportActionBar(_toolbar); SetupSupportActionBar(); // Set adapter to view pager and add OnPageChangeListener _pager.Adapter = adapter; _pager.AddOnPageChangeListener(this); // Setup tablayout with view pager _tabLayout.SetupWithViewPager(_pager); // Iterate over all tabs and set the custom view for (int i = 0; i < _tabLayout.TabCount; i++) { TabLayout.Tab tab = _tabLayout.GetTabAt(i); tab.SetCustomView(adapter.GetTabView(i)); } }
private void SetSelectedTabIcon(TabLayout.Tab tab, string icon, bool selected) { if (string.IsNullOrEmpty(icon)) { return; } if (selected) { var selectedResource = IdFromTitle(string.Format("{0}_selected", icon), ResourceManager.DrawableClass); if (selectedResource != 0) { tab.SetIcon(selectedResource); return; } } var resource = IdFromTitle(icon, ResourceManager.DrawableClass); tab.SetIcon(resource); }
void TabLayout.IOnTabSelectedListener.OnTabReselected(TabLayout.Tab tab) { // To have the logic only on he tab on position 1 if (tab == null || tab.Position != 1) { return; } if (tab.Text == "Play") { tab.SetText("Pause"); tab.SetIcon(Resource.Drawable.ionicons_2_0_1_pause_outline_25); App.pauseCard = false; } else { tab.SetText("Play"); tab.SetIcon(Resource.Drawable.ionicons_2_0_1_play_outline_25); App.pauseCard = true; } SetTintColor(tab, GetTabColor()); }
void UpdateTabIcons() { if (IsDisposed) { return; } TabLayout tabs = _tabLayout; if (tabs.TabCount != Element.Children.Count) { return; } for (var i = 0; i < Element.Children.Count; i++) { Page child = Element.Children[i]; TabLayout.Tab tab = tabs.GetTabAt(i); SetTabIconImageSource(child, tab); } }
void UpdateItemIconColor() { if (IsDisposed) { return; } if (IsBottomTabPlacement) { _bottomNavigationView.ItemIconTintList = GetItemIconTintColorState() ?? _orignalTabIconColors; } else { var colors = GetItemIconTintColorState() ?? _orignalTabIconColors; for (int i = 0; i < _tabLayout.TabCount; i++) { TabLayout.Tab tab = _tabLayout.GetTabAt(i); this.SetIconColorFilter(tab); } } }
void OnPagePropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == Page.TitleProperty.PropertyName) { var page = (Page)sender; var index = Element.Children.IndexOf(page); if (IsBottomTabPlacement) { IMenuItem tab = _bottomNavigationView.Menu.GetItem(index); tab.SetTitle(page.Title); } else { TabLayout.Tab tab = _tabLayout.GetTabAt(index); tab.SetText(page.Title); } } else if (e.PropertyName == Page.IconImageSourceProperty.PropertyName) { var page = (Page)sender; var index = Element.Children.IndexOf(page); if (IsBottomTabPlacement) { var menuItem = _bottomNavigationView.Menu.GetItem(index); _ = this.ApplyDrawableAsync(page, Page.IconImageSourceProperty, Context, icon => { menuItem.SetIcon(icon); }); } else { TabLayout.Tab tab = _tabLayout.GetTabAt(index); _ = this.ApplyDrawableAsync(page, Page.IconImageSourceProperty, Context, icon => { SetTabIcon(tab, icon); }); } } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); CurrentPlatform.Init(); byDateFilter = false; byAuthorFilter = false; // Set our view from the "main" layout resource base.SetContentView(PlanYourJourney.Resource.Layout.Main); List = new List <Arrangement>(); UpdateData(); ISharedPreferences settings = GetSharedPreferences("MyPrefsFile", 0); MyUsername = settings.GetString("author", ""); // Find views _pager = FindViewById <ViewPager>(PlanYourJourney.Resource.Id.pager); _tabLayout = FindViewById <TabLayout>(PlanYourJourney.Resource.Id.sliding_tabs); _adapter = new CustomPagerAdapter(this, SupportFragmentManager); _toolbar = FindViewById <Toolbar>(PlanYourJourney.Resource.Id.my_toolbar); // Setup Toolbar SetSupportActionBar(_toolbar); base.SupportActionBar.Title = GetString(PlanYourJourney.Resource.String.app_name); // Set adapter to view pager _pager.Adapter = _adapter; // Setup tablayout with view pager _tabLayout.SetupWithViewPager(_pager); // Iterate over all tabs and set the custom view for (int i = 0; i < 3; i++) { TabLayout.Tab tab = _tabLayout.GetTabAt(i); tab.SetCustomView(_adapter.GetTabView(i)); } }
void Handle_UpdateIcons(object sender, EventArgs e) { TabLayout tabs = layout; if (tabs == null) { return; } for (var i = 0; i < Element.Children.Count; i++) { var child = Element.Children[i].BindingContext as IIconChange; var icon = child.CurrentIcon; if (string.IsNullOrEmpty(icon)) { continue; } TabLayout.Tab tab = tabs.GetTabAt(i); SetCurrentTabIcon(tab, icon); } }
void OnPagePropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == Page.TitleProperty.PropertyName) { var page = (Page)sender; var index = Element.Children.IndexOf(page); if (IsBottomTabPlacement) { IMenuItem tab = _bottomNavigationView.Menu.GetItem(index); tab.SetTitle(page.Title); } else { TabLayout.Tab tab = _tabLayout.GetTabAt(index); tab.SetText(page.Title); } } else if (e.PropertyName == Page.IconImageSourceProperty.PropertyName) { var page = (Page)sender; var index = Element.Children.IndexOf(page); if (IsBottomTabPlacement) { var menuItem = _bottomNavigationView.Menu.GetItem(index); page.IconImageSource.LoadImage( _context, result => { menuItem.SetIcon(result.Value); }); } else { TabLayout.Tab tab = _tabLayout.GetTabAt(index); SetTabIconImageSource(page, tab); } } }
void UpdateTabIcons() { TabLayout tabs = _tabLayout; if (tabs.TabCount != Element.Children.Count) { return; } for (var i = 0; i < Element.Children.Count; i++) { Page child = Element.Children[i]; FileImageSource icon = child.Icon; if (string.IsNullOrEmpty(icon)) { continue; } TabLayout.Tab tab = tabs.GetTabAt(i); tab.SetIcon(ResourceManager.IdFromTitle(icon, ResourceManager.DrawableClass)); } }
protected override void SetTabIcon(TabLayout.Tab tab, FileImageSource icon) { base.SetTabIcon(tab, icon); if (tab.Text == "菜单" || tab.Text == "搜索") { tab.SetCustomView(Resource.Layout.CustomTablayout); var customView = Element as CustomTabbedPage; var imagebtn = tab.CustomView.FindViewById <Android.Widget.ImageButton>(Resource.Id.tabpage_btn); imagebtn.Background = tab.Icon; imagebtn.Click += (sender, e) => { if (tab.Text == "菜单") { CustomTabbedPage.OnMenuClicked(customView, EventArgs.Empty); } else if (tab.Text == "搜索") { CustomTabbedPage.OnSearchClick(customView, EventArgs.Empty); } }; } }
private void SetTab(TabLayout.Tab tab, string name) { try { int id = Resources.GetIdentifier(name, "drawable", Context.PackageName); tab.SetIcon(null); LinearLayout.LayoutParams linearLayoutParams = new LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); linearLayoutParams.SetMargins(0, -48, 0, 0); ImageView img = new ImageView(Context); img.LayoutParameters = linearLayoutParams; img.SetPadding(0, 0, 0, 48); img.SetImageResource(id); tab.SetCustomView(img); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.StackTrace); } }
void UpdateTabIcons() { TabLayout tabs = _tabLayout; if (tabs.TabCount != Element.Children.Count) { return; } for (var i = 0; i < Element.Children.Count; i++) { Page child = Element.Children[i]; FileImageSource icon = child.Icon; if (string.IsNullOrEmpty(icon)) { continue; } TabLayout.Tab tab = tabs.GetTabAt(i); SetTabIcon(tab, icon); } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = base.OnCreateView(inflater, container, savedInstanceState); viewPager = view.FindViewById <UnscrollingViewPager>(Resource.Id.points_view_pager); viewPager.SetPagingEnabled(true); PointsSmoothViewPagerHelper.Customize(viewPager); if (viewPager != null) { fragments = new List <MvxViewPagerFragmentInfo> { new MvxViewPagerFragmentInfo(tabTitles[0], typeof(PointsFragment), (Activity as MainActivity).vmHelper.PointsVM), new MvxViewPagerFragmentInfo(tabTitles[1], typeof(LeaderboardFragment), (Activity as MainActivity).vmHelper.LeaderboardVM), new MvxViewPagerFragmentInfo(tabTitles[2], typeof(TransactionsFragment), (Activity as MainActivity).vmHelper.TransactionsVM), }; pagerAdapter = new MvxCachingFragmentStatePagerAdapter(Activity, this.ChildFragmentManager, fragments); viewPager.Adapter = pagerAdapter; tabLayout = view.FindViewById <TabLayout>(Resource.Id.points_tabs); tabLayout.SetupWithViewPager(viewPager); viewPager.AddOnPageChangeListener(this); tabLayout.SetupWithViewPager(viewPager); for (int i = 0; i < tabLayout.TabCount; i++) { TabLayout.Tab tab = tabLayout.GetTabAt(i); tab.SetCustomView(GetTabView(i)); } tabLayout.AddOnTabSelectedListener(this); TabHighlited(tabLayout.GetTabAt(0)); } ViewModel.AddCurrentVM += ViewModel_AddCurrentVM; (Activity as MainActivity).vmHelper.PointsVM.DetailsViewOpened += (s, e) => { viewPager.SetPagingEnabled(!e); }; return(view); }
void UpdateTabIcons() { if (IsDisposed) { return; } TabLayout tabs = _tabLayout; if (tabs.TabCount != Element.Children.Count) { return; } for (var i = 0; i < Element.Children.Count; i++) { Page child = Element.Children[i]; TabLayout.Tab tab = tabs.GetTabAt(i); _ = this.ApplyDrawableAsync(child, Page.IconImageSourceProperty, Context, icon => { SetTabIcon(tab, icon); }); } }
void OnPagePropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == Page.TitleProperty.PropertyName) { var page = (Page)sender; var index = Element.Children.IndexOf(page); if (IsBottomTabPlacement) { IMenuItem tab = _bottomNavigationView.Menu.GetItem(index); tab.SetTitle(page.Title); } else { TabLayout.Tab tab = _tabLayout.GetTabAt(index); tab.SetText(page.Title); } } else if (e.PropertyName == Page.IconProperty.PropertyName) { var page = (Page)sender; var index = Element.Children.IndexOf(page); FileImageSource icon = page.Icon; if (IsBottomTabPlacement) { var menuItem = _bottomNavigationView.Menu.GetItem(index); menuItem.SetIcon(GetIconDrawable(icon)); } else { TabLayout.Tab tab = _tabLayout.GetTabAt(index); SetTabIcon(tab, icon); } } }
private void InitTabs() { for (var i = 0; i < _adapter.TabIconsInactive.Length; i++) { var tab = _tabLayout.NewTab(); var tabView = new ImageView(this) { Id = Android.Resource.Id.Icon }; tabView.SetScaleType(ImageView.ScaleType.CenterInside); tabView.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, _tabHeight); tab.SetCustomView(tabView); _tabLayout.AddTab(tab); if (i == _adapter.TabIconsInactive.Length - 1) { SetProfileChart(_tabLayout.LayoutParameters.Height); } tab.SetIcon(ContextCompat.GetDrawable(this, _adapter.TabIconsInactive[i])); } SelectTab(BasePresenter.User.SelectedTab); _prevTab = _tabLayout.GetTabAt(BasePresenter.User.SelectedTab); _viewPager.OffscreenPageLimit = _adapter.Count - 1; }
private void OnTabLayoutOnTabSelected(object sender, TabLayout.TabSelectedEventArgs e) { if (e.Tab.Position == 2) { if (PermissionChecker.CheckSelfPermission(this, Android.Manifest.Permission.Camera) == (int)Permission.Granted && PermissionChecker.CheckSelfPermission(this, Android.Manifest.Permission.WriteExternalStorage) == (int)Permission.Granted) { _prevTab.Select(); var intent = new Intent(this, typeof(CameraActivity)); StartActivity(intent); } else { //Replace for Permission request this.ShowAlert(LocalizationKeys.CheckPermission); } } else { SelectTab(e.Tab.Position); _prevTab = e.Tab; BasePresenter.User.SelectedTab = e.Tab.Position; } }
void TabLayout.IOnTabSelectedListener.OnTabUnselected(TabLayout.Tab tab) { }
protected virtual void SetTabIcon(TabLayout.Tab tab, FileImageSource icon) { tab.SetIcon(ResourceManager.IdFromTitle(icon, ResourceManager.DrawableClass)); }
public void OnTabSelected(TabLayout.Tab tab) { viewPager.CurrentItem = tab.Position; adapter.OnRefresh(tab.Position); }
void SetIconColorFilter(TabLayout.Tab tab) { SetIconColorFilter(tab, _tabLayout.GetTabAt(_tabLayout.SelectedTabPosition) == tab); }
void TabLayout.IOnTabSelectedListener.OnTabUnselected(TabLayout.Tab tab) { SetIconColorFilter(tab, false); }
void TabLayout.IOnTabSelectedListener.OnTabReselected(TabLayout.Tab tab) { System.Diagnostics.Debug.WriteLine("Tab Reselected"); //Handle Tab Reselected }
public void OnTabSelected(TabLayout.Tab tab) { _viewPagerHome.CurrentItem = tab.Position; currentPosition = tab.Position; }
private ITabItem GetTabItem(TabLayout.Tab item, IList <ITabItem> tabItems) { return(tabItems.FirstOrDefault(m => m.Title.Equals(item.Text))); }
void TabLayout.IOnTabSelectedListener.OnTabUnselected(TabLayout.Tab tab) { var child = Element.Children[tab.Position]; SetSelectedTabIcon(tab, child.Icon, false); }
protected virtual void SetTabIcon(TabLayout.Tab tab, FileImageSource icon) { tab.SetIcon(GetIconDrawable(icon)); this.SetIconColorFilter(tab); }
public void OnTabUnselected(TabLayout.Tab tab) { }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.ActivityTest); //Работа с контекстом приложения AppApplication myApp = (AppApplication)ApplicationContext; // Find views viewPager = FindViewById <ViewPager>(Resource.Id.pager); tabLayout = FindViewById <TabLayout>(Resource.Id.sliding_tabs); AdapterCustomPager adapter = new AdapterCustomPager(this, SupportFragmentManager); toolbar = FindViewById <SupportToolbar>(Resource.Id.my_toolbar); mButtonSettingsApp = FindViewById <Button>(Resource.Id.settingsApp); mButtonSettingsApp.Click += (sender, args) => { Intent IntentSettings = new Intent(this, typeof(ActivitySettings)); IntentSettings.PutExtra("settings", "app"); StartActivity(IntentSettings); }; mButtonSettingsAdmin = FindViewById <Button>(Resource.Id.settingsAdmin); mButtonSettingsAdmin.Click += (sender, args) => { Intent IntentSettings = new Intent(this, typeof(ActivitySettings)); IntentSettings.PutExtra("settings", "admin"); StartActivity(IntentSettings); }; mButtonSettingsUser = FindViewById <Button>(Resource.Id.settingsUser); mButtonSettingsUser.Click += (sender, args) => { Intent IntentSettings = new Intent(this, typeof(ActivitySettings)); IntentSettings.PutExtra("settings", "user"); StartActivity(IntentSettings); }; mButtonActivityMessage = FindViewById <Button>(Resource.Id.activityMessage); mButtonActivityMessage.Click += (sender, args) => { Intent IntentMessage = new Intent(this, typeof(ActivityMessage)); StartActivity(IntentMessage); }; Button mButtonActivityMap = FindViewById <Button>(Resource.Id.activityMap); mButtonActivityMap.Click += (sender, args) => { Intent IntentMessage = new Intent(this, typeof(ActivityMaps)); StartActivity(IntentMessage); }; // Setup Toolbar SetSupportActionBar(toolbar); SupportActionBar.Title = "View для тестирования"; SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetDisplayShowHomeEnabled(true); setupViewPager(viewPager, adapter); tabLayout.SetupWithViewPager(viewPager); setupTabIcons(); for (int i = 0; i < tabLayout.TabCount; i++) { TabLayout.Tab tab = tabLayout.GetTabAt(i); tab.SetCustomView(adapter.GetTabView(i)); } }