Ejemplo n.º 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);

            mToolbar = FindViewById<SupportToolbar>(Resource.Id.toolbar);
            mDrawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
            mLeftDrawer = FindViewById<ListView>(Resource.Id.left_drawer);
            homeFragment = new HomeFragment();

            profileFragment = new ProfileFragment();
            mStackFragments = new Stack<SupportFragment>();

            mLeftDrawer.Tag = 0;

            SetSupportActionBar(mToolbar);

            mLeftDataSet = new List<string>();
            mLeftDataSet.Add ("Left Item 1");
            mLeftDataSet.Add ("Left Item 2");
            mLeftAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, mLeftDataSet);
            mLeftDrawer.Adapter = mLeftAdapter;
            mLeftDrawer.ItemClick+= MenuListView_ItemClick;

            mDrawerToggle = new MyActionBarDrawerToggle(
                this,							//Host Activity
                mDrawerLayout,					//DrawerLayout
                Resource.String.openDrawer,		//Opened Message
                Resource.String.closeDrawer		//Closed Message
            );

            mDrawerLayout.SetDrawerListener(mDrawerToggle);
            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayShowTitleEnabled(true);
            mDrawerToggle.SyncState();

            if (bundle != null)
            {
                if (bundle.GetString("DrawerState") == "Opened")
                {
                    SupportActionBar.SetTitle(Resource.String.openDrawer);
                }

                else
                {
                    SupportActionBar.SetTitle(Resource.String.closeDrawer);
                }
            }

            else
            {
                //This is the first the time the activity is ran
                SupportActionBar.SetTitle(Resource.String.closeDrawer);
            }

            Android.Support.V4.App.FragmentTransaction tx = SupportFragmentManager.BeginTransaction();

            tx.Add(Resource.Id.main, homeFragment);
            tx.Add(Resource.Id.main, profileFragment);
            tx.Hide(profileFragment);

            mCurrentFragment = homeFragment;
            tx.Commit();
        }
Ejemplo n.º 2
0
        public static Android.Support.V4.App.Fragment newInstance(Context context)
        {
            ProfileFragment busrouteFragment = new ProfileFragment();

            return(busrouteFragment);
        }
Ejemplo n.º 3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            mToolbar      = FindViewById <SupportToolbar>(Resource.Id.toolbar);
            mDrawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            mLeftDrawer   = FindViewById <ListView>(Resource.Id.left_drawer);
            homeFragment  = new HomeFragment();

            profileFragment = new ProfileFragment();
            mStackFragments = new Stack <SupportFragment>();


            mLeftDrawer.Tag = 0;


            SetSupportActionBar(mToolbar);

            mLeftDataSet = new List <string>();
            mLeftDataSet.Add("Left Item 1");
            mLeftDataSet.Add("Left Item 2");
            mLeftAdapter           = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, mLeftDataSet);
            mLeftDrawer.Adapter    = mLeftAdapter;
            mLeftDrawer.ItemClick += MenuListView_ItemClick;


            mDrawerToggle = new MyActionBarDrawerToggle(
                this,                                                   //Host Activity
                mDrawerLayout,                                          //DrawerLayout
                Resource.String.openDrawer,                             //Opened Message
                Resource.String.closeDrawer                             //Closed Message
                );

            mDrawerLayout.SetDrawerListener(mDrawerToggle);
            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayShowTitleEnabled(true);
            mDrawerToggle.SyncState();

            if (bundle != null)
            {
                if (bundle.GetString("DrawerState") == "Opened")
                {
                    SupportActionBar.SetTitle(Resource.String.openDrawer);
                }

                else
                {
                    SupportActionBar.SetTitle(Resource.String.closeDrawer);
                }
            }

            else
            {
                //This is the first the time the activity is ran
                SupportActionBar.SetTitle(Resource.String.closeDrawer);
            }

            Android.Support.V4.App.FragmentTransaction tx = SupportFragmentManager.BeginTransaction();

            tx.Add(Resource.Id.main, homeFragment);
            tx.Add(Resource.Id.main, profileFragment);
            tx.Hide(profileFragment);

            mCurrentFragment = homeFragment;
            tx.Commit();
        }
 public static Android.Support.V4.App.Fragment newInstance(Context context)
 {
     ProfileFragment busrouteFragment = new ProfileFragment();
     return busrouteFragment;
 }