protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); EditText username = FindViewById <EditText>(Resource.Id.userName); EditText password = FindViewById <EditText>(Resource.Id.passWord); //editText1.Text = "Yay, edit works!"; //editText1.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => { // textView2.Text = e.Text.ToString(); //}; Button authenticateButton = FindViewById <Button>(Resource.Id.authenticateButton); authenticateButton.Click += (sender, e) => { string un = username.Text; string pw = password.Text; if (checkCredentials(un, pw)) { var intent = new Intent(this, typeof(EventsPageActivity)); StartActivity(intent); } }; //Load hackathons List <Hackathon> hacks; using (XmlReader reader = Resources.GetXml(Resource.Xml.Hackathons)) { hacks = Hackathon.LoadHackathons(reader); } }
/// <summary> /// Loads all hackathons' data from Assets/Hackathons /// <para>Supply Assets property within onCreate() method to run this function</para> /// </summary> /// <param name="assets">AssetManager to read from Assets folder</param> public static List <Hackathon> LoadHackathons(XmlReader reader) { List <Hackathon> hacks = new List <Hackathon>(); reader.Read(); //Skip to first hackathon Hackathon current = new Hackathon();; try { CultureInfo provider = CultureInfo.InvariantCulture; while (reader.Read()) { switch (reader.Name) { case "hackathon": if (current.Name != null) { hacks.Add(current); } current = new Hackathon(); break; case "name": reader.Read(); current.Name = reader.Value; reader.Read(); break; case "start": reader.Read(); current.StartDate = DateTime.ParseExact(reader.Value, Constants.DATETIME_FORMAT, provider); reader.Read(); break; case "end": reader.Read(); current.EndDate = DateTime.ParseExact(reader.Value, Constants.DATETIME_FORMAT, provider); reader.Read(); break; case "loc": reader.Read(); current.Location = reader.Value; reader.Read(); break; case "desc": reader.Read(); current.Description = reader.Value; reader.Read(); break; case "img": reader.Read(); Stream bmp = Application.Context.Assets.Open(reader.Value); current.Background = BitmapFactory.DecodeStream(bmp); reader.Read(); break; } } } catch (Java.IO.IOException ex) { Log.Error(Constants.LOG_TAG, ex.Message); } return(hacks); }