private void CreateNewNote() { Note note = new Note(MainActivity.countNotes + 1, textView.Text, titleView.Text); SerializationNote.SaveAsBinaryFormat(note, String.Format("Note" + note.Id)); currentNode = note; }
private void SaveNote() { File.Delete(Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "Note" + currentNode.Id)); Note note = new Note(currentNode.Id, textView.Text, titleView.Text); SerializationNote.SaveAsBinaryFormat(note, String.Format("Note" + note.Id)); currentNode = note; Toast.MakeText(this, "Saved", ToastLength.Short).Show(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); ListView listViewNotes = FindViewById <ListView>(Resource.Id.listView1); Button button = FindViewById <Button>(Resource.Id.button1); int id = 1; while (id < 1000) { var backingFile = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "Note" + id); if (File.Exists(backingFile)) { Note note = SerializationNote.LoadFromBinaryFile("Note" + id); Notes.Add(note); countNotes = id; } id++; } ArrayAdapter <Note> adapter = new ArrayAdapter <Note>(this, Android.Resource.Layout.SimpleListItem1, Notes); listViewNotes.Adapter = adapter; listViewNotes.ItemClick += (s, e) => { note = Notes[e.Position]; Intent intent = new Intent(this, typeof(SingleNote)); intent.PutExtra("Id", note.Id); intent.PutExtra("Title", note.Title); intent.PutExtra("Text", note.Text); StartActivity(intent); }; button.Click += (s, e) => { Intent intent = new Intent(this, typeof(SingleNote)); StartActivity(intent); }; }