//TextView _mainTextView;

        protected override void OnCreate(Bundle savedInstanceState)
        {
            //RequestWindowFeature(Android.Views.WindowFeatures.RightIcon);
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.HomeScreen);

            locationManager = (LocationManager)GetSystemService(Context.LocationService);

            //Create criteria for the location service using the coarse constant
            Criteria criteriaForLocationService = new Criteria
            {
                Accuracy         = Accuracy.Coarse,
                PowerRequirement = Power.Medium
            };

            //Set provider
            provider = locationManager.GetBestProvider(criteriaForLocationService, true);

            Location location = locationManager.GetLastKnownLocation(provider);

            if (location == null)
            {
                System.Diagnostics.Debug.WriteLine("No location");
            }

            _username = Intent.GetStringExtra("username");

            _DrawerLayout = FindViewById <DrawerLayout>(Resource.Id.myDrawer);
            _LeftDrawer   = FindViewById <ListView>(Resource.Id.leftListView);

            TextView txtGreeting = FindViewById <TextView>(Resource.Id.txtGreeting);

            txtGreeting.Text = "Welcome back, " + _username;

            _leftItems.Add("Contacts");
            _leftItems.Add("Midpoint Calculator");
            _leftItems.Add("Edit Profile");

            _DrawerToggle = new HomescreenActionBarDrawerToggle(this, _DrawerLayout, Resource.Drawable.ic_drawer, Resource.String.open_drawer, Resource.String.close_drawer);

            _leftAdapter        = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, _leftItems);
            _LeftDrawer.Adapter = _leftAdapter;

            _DrawerLayout.SetDrawerListener(_DrawerToggle);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ActionBar.SetHomeButtonEnabled(true);

            _LeftDrawer.ItemClick += _LeftDrawer_ItemClick;
        }
Esempio n. 2
0
        protected override void OnCreate(Bundle bundle)
        {
            SetTheme (Resource.Style.Theme_Sherlock);
            base.OnCreate (bundle);
            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);
            list = FindViewById<ListView> (Resource.Id.list);
            drawer = FindViewById<DrawerLayout> (Resource.Id.drawer_layout);
            adapter = new CustomAdapter (this, list_text);
            list.Adapter = adapter;
            fragA = new FragmentA ();
            fragB = new FragmentB ();
            list.ItemClick += (sender, e) => {
                ListView item = sender as ListView;
                int pos = item.CheckedItemPosition;
                TextView t = (TextView) e.View.FindViewById(Resource.Id.textView1);
                string mess = t.Text;
                Bundle args = new Bundle();
                args.PutString("message", mess);
                transaction = SupportFragmentManager.BeginTransaction();
                switch (pos){
                case 0:
                    if(!fragA.IsVisible){
                        fragA.Arguments = args;
                        transaction.Replace(Resource.Id.frame, fragA);
                    }
                    break;
                case 1:
                    if(!fragB.IsVisible){
                        fragB.Arguments = args;
                        transaction.Replace(Resource.Id.frame, fragB);
                    }
                    break;

                }
                transaction.Commit();
                list.SetItemChecked(pos, true);
                drawer.CloseDrawer(list);

            };

            mDrawerToggle = new Android.Support.V4.App.ActionBarDrawerToggle(this, drawer,  Resource.Drawable.ic_drawer, Resource.String.drawer_open, Resource.String.drawer_close)
            {
            };
            drawer.SetDrawerListener(mDrawerToggle);
            SupportActionBar.SetDisplayHomeAsUpEnabled (true);
            SupportActionBar.SetHomeButtonEnabled(true);
            // Get our button from the layout resource,
            // and attach an event to it
        }