public static Android.Support.V4.App.Fragment newInstance(Context context) { LoginFragment busrouteFragment = new LoginFragment(); return(busrouteFragment); }
protected override void OnCreate(Bundle bundle) { try { base.OnCreate(bundle); SetContentView(Resource.Layout.activity_main); //var x = MakeAsyncRequest("http://116.193.133.150/publicweb/Helpdesk_API/Login/GetDefault", "application/json"); //var x = SampleAPICall(); //throw new Exception(x.Result.ToString()); /*var x = SampleAPICall(); * var y = x.Result.ReadAsStringAsync();*/ mToolbar = FindViewById <SupportToolbar>(Resource.Id.toolbar); mDrawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); mLeftDrawer = FindViewById <ListView>(Resource.Id.left_drawer); loginFragment = new LoginFragment(); registrationFragment = new RegistrationFragment(); mStackFragments = new Stack <SupportFragment>(); mLeftDrawer.Tag = 0; SetSupportActionBar(mToolbar); mLeftDataSet = new List <string>(); mLeftDataSet.Add("Login"); mLeftDataSet.Add("Register"); mLeftAdapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, mLeftDataSet); mLeftDrawer.Adapter = mLeftAdapter; mLeftDrawer.ItemClick += MenuListView_ItemClick; /*try * { * for (int i = 0; i < mLeftDrawer.Adapter.Count; i++) * { * var child = mLeftDrawer.Adapter.GetView(i, null, mLeftDrawer); * //((TextView)child).SetLinkTextColor(Resources.GetColorStateList(Resource.Color.colorWhite)); * //((TextView)child).SetTextColor(Android.Graphics.Color.White); * } * } * catch { }*/ mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, Resource.String.openDrawer, Resource.String.closeDrawer); mDrawerLayout.SetDrawerListener(mDrawerToggle); SupportActionBar.SetHomeButtonEnabled(true); SupportActionBar.SetDisplayShowTitleEnabled(true); SupportActionBar.SetDisplayHomeAsUpEnabled(true); mDrawerToggle.SyncState(); if (bundle != null) { if (bundle.GetString("DrawerState") == "Opened") { SupportActionBar.SetTitle(Resource.String.openDrawer); } else { SupportActionBar.SetTitle(Resource.String.closeDrawer); } } else { SupportActionBar.SetTitle(Resource.String.closeDrawer); } IList <Android.Support.V4.App.Fragment> fragmentsarray = SupportFragmentManager.Fragments; if (fragmentsarray != null && fragmentsarray.Count > default(int)) { foreach (Android.Support.V4.App.Fragment fragment in fragmentsarray) { string tag = fragment.Tag; Android.Support.V4.App.FragmentTransaction tx = SupportFragmentManager.BeginTransaction(); tx.Replace(Resource.Id.main, fragment, fragment.Tag); tx.Commit(); break; } } else { Android.Support.V4.App.FragmentTransaction tx = SupportFragmentManager.BeginTransaction(); tx.Replace(Resource.Id.main, loginFragment, Constants.login); tx.Commit(); } } catch (Exception ex) { this.RunOnUiThread(() => { Android.App.AlertDialog.Builder alertDiag = new Android.App.AlertDialog.Builder(this); alertDiag.SetTitle(Resource.String.DialogHeaderError); alertDiag.SetMessage(ex.Message); alertDiag.SetIcon(Resource.Drawable.alert); alertDiag.SetPositiveButton(Resource.String.DialogButtonOk, (senderAlert, args) => { }); Dialog diag = alertDiag.Create(); diag.Show(); diag.SetCanceledOnTouchOutside(false); }); } }