public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.Inflate(Resource.Layout.Calendar, container, false); calendarView = view.FindViewById <CalendarView>(Resource.Id.calendarView1); calendarView.DateChange += DateSelect; //database connection var db = new SQLiteConnection(Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "zdrowieplus.db")); db.CreateTable <Reminder>(); DateTime nextDay = DateTime.Today.AddDays(1); events.Clear(); events = db.Table <Reminder>().Where(e => e.Date >= DateTime.Today && e.Date < nextDay).OrderBy(e => e.Date).ToList(); listAdapter = new ListViewCalendarAdapter(this.Activity, events); remindersListView = view.FindViewById <ListView>(Resource.Id.listViewCalendar); remindersListView.Adapter = listAdapter; remindersListView.FastScrollEnabled = true; remindersListView.ItemClick += reminder_ItemClick; return(view); }
private void DateSelect(object sender, CalendarView.DateChangeEventArgs e) { // Month is a value beetwen 0 and 11 DateTime selectedDate = new DateTime(e.Year, e.Month + 1, e.DayOfMonth); //database connection var db = new SQLiteConnection(Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "zdrowieplus.db")); db.CreateTable <Reminder>(); DateTime nextDay = selectedDate.AddDays(1); events.Clear(); events = db.Table <Reminder>().Where(x => x.Date >= selectedDate && x.Date < nextDay).OrderBy(x => x.Date).ToList(); listAdapter = new ListViewCalendarAdapter(this.Activity, events); remindersListView.Adapter = listAdapter; }