Example #1
0
        public bool OnNavigationItemSelected(IMenuItem item)
        {
            transaction = FragmentManager.BeginTransaction();
            hideAllFragment(transaction);
            switch (item.ItemId)
            {
            case Resource.Id.navigation_home:
                if (f1 == null)
                {
                    f1 = new cityFragment();
                    transaction.Add(Resource.Id.myfragment, f1);
                }
                else
                {
                    transaction.Show(f1);
                }
                break;

            case Resource.Id.navigation_dashboard:
                if (f2 == null)
                {
                    f2 = new MyFragment();
                    transaction.Add(Resource.Id.myfragment, f2);
                }
                else
                {
                    transaction.Show(f2);
                }
                break;

            //textMessage.SetText(Resource.String.title_dashboard);
            //return true;
            case Resource.Id.navigation_notifications:
                // textMessage.SetText(Resource.String.title_notifications);
                // return true;
                if (f3 == null)
                {
                    f3 = new MyFragment();
                    transaction.Add(Resource.Id.myfragment, f3);
                }
                else
                {
                    transaction.Show(f3);
                }
                break;
            }
            transaction.Commit();
            return(false);
        }
Example #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);
            transaction = FragmentManager.BeginTransaction();
            myfragment  = (FrameLayout)FindViewById(Resource.Id.myfragment);
            textMessage = FindViewById <TextView>(Resource.Id.message);
            BottomNavigationView navigation = FindViewById <BottomNavigationView>(Resource.Id.navigation);

            navigation.SetOnNavigationItemSelectedListener(this);
            cityFragment f = new cityFragment();

            //MyFragment f = new MyFragment();
            transaction.Add(Resource.Id.myfragment, f);
            transaction.Commit();
        }