private void DonorsAdapter_DeleteClick(object sender, UserAdapterClickEventArgs e) { var donor = listOfDonors[e.Position]; Android.Support.V7.App.AlertDialog.Builder DeleteAlert = new Android.Support.V7.App.AlertDialog.Builder(this); DeleteAlert.SetMessage("Are you sure?"); DeleteAlert.SetTitle("Delete Donor"); DeleteAlert.SetPositiveButton("Delete", (alert, args) => { listOfDonors.RemoveAt(e.Position); donorsAdapter.NotifyItemRemoved(e.Position); // donorsAdapter.NotifyDataSetChanged(); <- not using because refreshes whole view. Potential loss of data // Update shared preferences when a row is deleted from list string jsonString = JsonConvert.SerializeObject(listOfDonors); // Serializes list we passed in into JSON string (using JSON Newton Nuget) editor.PutString("donors", jsonString); editor.Apply(); // Saves donors to shared preferences }); DeleteAlert.SetNegativeButton("Cancel", (alert, args) => { DeleteAlert.Dispose(); }); DeleteAlert.Show(); }
// What happens when you click "Call" private void DonorsAdapter_CallClick(object sender, UserAdapterClickEventArgs e) { var donor = listOfDonors[e.Position]; Android.Support.V7.App.AlertDialog.Builder CallAlert = new Android.Support.V7.App.AlertDialog.Builder(this); CallAlert.SetMessage("Call " + donor.Fullname); CallAlert.SetPositiveButton("Call", (alert, args) => { var uri = Android.Net.Uri.Parse("tel:" + donor.Phone); var intent = new Intent(Intent.ActionDial, uri); StartActivity(intent); }); CallAlert.SetNegativeButton("Cancel", (alert, args) => { CallAlert.Dispose(); }); CallAlert.Show(); }
private void DonorsAdapter_MailClick(object sender, UserAdapterClickEventArgs e) { var donor = listOfDonors[e.Position]; Android.Support.V7.App.AlertDialog.Builder MailAlert = new Android.Support.V7.App.AlertDialog.Builder(this); MailAlert.SetMessage("Send Mail to " + donor.Fullname); MailAlert.SetPositiveButton("Send", (alert, args) => { Intent intent = new Intent(); intent.SetType("plain/text"); intent.SetAction(Intent.ActionSend); intent.PutExtra(Intent.ExtraEmail, new string[] { donor.Email }); intent.PutExtra(Intent.ExtraSubject, new string[] { "Enter your message here." }); StartActivity(intent); }); MailAlert.SetNegativeButton("Cancel", (alert, args) => { MailAlert.Dispose(); }); MailAlert.Show(); }
private void DonorsAdapter_ItemClick(object sender, UserAdapterClickEventArgs e) { Toast.MakeText(this, "Row was clicked", ToastLength.Short).Show(); }