void CommitCreation(string name, DatePicker datepicker, TimePicker timepicker) { RememberThing rememberThing = new RememberThing(); rememberThing.Name = name; int hours = 0; int minutes = 0; int seconds = 0; // Init values if (Build.VERSION.SdkInt >= BuildVersionCodes.M) { hours = timepicker.Hour; minutes = timepicker.Minute; } else { hours = timepicker.CurrentHour.IntValue(); minutes = timepicker.CurrentMinute.IntValue(); } rememberThing.Deadline = new DateTime(datepicker.DateTime.Year, datepicker.DateTime.Month, datepicker.DateTime.Day, hours, minutes, seconds); adapter.RememberThings.Insert(0, rememberThing); adapter.NotifyItemInserted(0); }
/// <summary> /// Populates the list. /// </summary> void PopulateList() { // Let's create some dummy elements RememberThing thing1 = new RememberThing(); thing1.Name = "Bring the milk"; thing1.Deadline = DateTime.Now.AddMinutes(10); RememberThing thing2 = new RememberThing(); thing2.Name = "Bring the bread"; thing2.Deadline = DateTime.Now.AddMinutes(20); List <RememberThing> rememberThings = new List <RememberThing>(); rememberThings.Add(thing1); rememberThings.Add(thing2); adapter = new RememberThingsAdapter(rememberThings); recyclerView.SetAdapter(adapter); }
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { RememberThing rememberThing = RememberThings[position]; (holder as RememberThingsViewHolder).BindViewHolder(rememberThing); }
public void BindViewHolder(RememberThing rememberThing) { name.Text = rememberThing.Name; deadline.Text = rememberThing.Deadline.ToString(); }