I do not have to do too much of the explanation, the data before the operation also cited examples, here directly paste the deletion and modification of the code.
Public Override BOOLonoptionsitemselected (Imenuitem item) {Switch(item. ItemId) { Case 1: {Android.App.AlertDialog.Builder Builder=NewAlertdialog.builder ( This); Alertdialog AD=Builder. Create (); Ad. Settitle ("whether to delete"); Ad. Setbutton ("is a", (s, e) = ={Sqlite DBHelper=NewSqlite ( This); Sqlitedatabase DB=dbhelper.writabledatabase; Contentvalues NCV=Newcontentvalues (); varNID = Intent.getstringextra ("ID"); NCv. Put ("Context", Edtext. Text); Db. Delete ("Notebooksql","_id =?",New string[] {NID. ToString ()}); varIntentAct2 =NewIntent ( This,typeof(Activity1)); StartActivity (INTENTACT2); Toast.maketext ( This,"has been removed", Toastlength.short). Show (); This. Finish (); }); Ad. SetButton2 ("No", (s, e) = = { }); Ad. Show (); } Break; Case 2: {Sqlite dbhelper=NewSqlite ( This); Sqlitedatabase DB=dbhelper.writabledatabase; Contentvalues NCV=Newcontentvalues (); varNID = Intent.getstringextra ("ID"); NCv. Put ("Context", Edtext. Text); Db. Update ("Notebooksql", NCV,"_id =?",New string[] {NID. ToString ()}); varIntentAct2 =NewIntent ( This,typeof(Activity1)); StartActivity (INTENTACT2); Toast.maketext ( This,"has been saved", Toastlength.short). Show (); This. Finish (); } Break; CaseAndroid.Resource.Id.Home: {varIntent =NewIntent ( This,typeof(Activity1)); StartActivity (Intent); This. Finish (); } Break; } return true; }
As follows
Xamarin Android Notepad (iii) pruning