public void UpdateTabs(int selectedPosition, TabLayout tabs, Toolbar tlb, TabsFragmentPagerAdapter adapter)
 {
     tabs.GetTabAt(selectedPosition).Icon.SetColorFilter(Selected, PorterDuff.Mode.SrcIn);
     tabs.GetTabAt(1 - selectedPosition).Icon.SetColorFilter(Deselected, PorterDuff.Mode.SrcIn);
     tlb.Title = adapter.GetTitle(selectedPosition);
 }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);


            var tlbMain = FindViewById <Toolbar>(Resource.Id.topToolbar);

            tlbMain.InflateMenu(Resource.Menu.maintoolbar);

            SetSupportActionBar(tlbMain);
            SupportActionBar.SetDisplayShowTitleEnabled(true);
            SupportActionBar.SetTitle(Resource.String.ApplicationName);

            var mapFrag   = new MapFrag();
            var listFrag  = new ListFrag();
            var fragments = new Fragment[]
            {
                listFrag,
                mapFrag
            };

            var titles = Android.Runtime.CharSequence.ArrayFromStringArray(new[]
            {
                "Strikes",
                "Map",
            });

            var viewPager = FindViewById <ViewPager>(Resource.Id.viewpager);
            var adapter   = new TabsFragmentPagerAdapter(SupportFragmentManager, fragments, titles);

            viewPager.Adapter = adapter;

            var tabLayout = FindViewById <TabLayout>(Resource.Id.tabs);

            tabLayout.SetupWithViewPager(viewPager);

            listFrag.Refreshed += delegate
            {
                mapFrag.MapReadyAction += delegate
                {
                    mapFrag.AddMarkers(listFrag.StrikeList);
                };
            };

            mapFrag.MapReadyAction += delegate
            {
                listFrag.Refreshed += delegate
                {
                    mapFrag.AddMarkers(listFrag.StrikeList);
                };
            };

            Selected   = new Color(ContextCompat.GetColor(this, Resource.Color.selectedTab));
            Deselected = new Color(ContextCompat.GetColor(this, Resource.Color.normalTab));

            tabLayout.GetTabAt(0).SetIcon(Resource.Drawable.ic_list_white_24dp);
            tabLayout.GetTabAt(1).SetIcon(Resource.Drawable.ic_map_white_24dp);

            UpdateTabs(viewPager.CurrentItem, tabLayout, tlbMain, adapter);

            viewPager.PageSelected += (sender, args) =>
            {
                UpdateTabs(args.Position, tabLayout, tlbMain, adapter);
            };
        }