public void PopulateList()
        {
            // Retrieve all our notes and put them in the list
            var notes = NoteRepository.GetAllNotes();
            //var adapter = new ArrayAdapter<Note> (this, Resource.Layout.noteslist_item, notes.ToList ());
            var adapter = new NoteAdapter(this, this, Resource.Layout.NoteListRow, notes.ToArray());

            ListAdapter = adapter;
        }
        protected override void OnPause()
        {
            base.OnPause();

            // If this was a new note and no content was added, don't save it
            if (IsFinishing && note.Id == -1 && text_view.Text.Length == 0)
            {
                return;
            }

            // Save the note
            note.Body = text_view.Text;
            NoteRepository.SaveNote(note);
        }
        public override bool OnContextItemSelected(IMenuItem item)
        {
            var info = (AdapterView.AdapterContextMenuInfo)item.MenuInfo;
            var note = (Note)ListAdapter.GetItem(info.Position);

            switch (item.ItemId)
            {
            case MENU_ITEM_DELETE: {
                // Delete the note that the context menu is for
                NoteRepository.DeleteNote(note);
                PopulateList();
                return(true);
            }
            }

            return(false);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set the layout for this activity.  You can find it in res/layout/note_editor.xml
            SetContentView(Resource.Layout.NoteEditor);

            // The text view for our note, identified by its ID in the XML file.
            text_view = FindViewById <EditText> (Resource.Id.note);

            // Get the note
            var note_id = Intent.GetLongExtra("note_id", -1L);

            if (note_id < 0)
            {
                note = new Note();
            }
            else
            {
                note = NoteRepository.GetNote(note_id);
            }
        }