zoukankan      html  css  js  c++  java
  • Xamarin Android 记事本(三)删改

    这篇我就不做太多的说明了,数据操作之前也都举过例子了,这里就直接贴出删除和修改的代码。

     public override bool OnOptionsItemSelected(IMenuItem item)
            {
                switch (item.ItemId)
                {
                    case 1:
                        {
                            Android.App.AlertDialog.Builder builder = new AlertDialog.Builder(this);
                            AlertDialog ad = builder.Create();
                            ad.SetTitle("是否删除");                    
                            ad.SetButton("", (s, e) =>
                            {
                                Sqlite dbHelper = new Sqlite(this);
                                SQLiteDatabase db = dbHelper.WritableDatabase;
                                ContentValues ncv = new ContentValues();
                                var NID = Intent.GetStringExtra("id");
                                ncv.Put("context", edtext.Text);
                                db.Delete("NoteBooksql", " _id = ? ", new string[] { NID.ToString() });
                                var intentAct2 = new Intent(this, typeof(Activity1));
                                StartActivity(intentAct2);
                                Toast.MakeText(this, "已删除", ToastLength.Short).Show();
                                this.Finish();
                               
                            });
                            ad.SetButton2("", (s, e) => { });
                            ad.Show();
                            
                        } break;
                    case 2:
                         {
                             Sqlite dbHelper = new Sqlite(this);
                             SQLiteDatabase db = dbHelper.WritableDatabase;
                             ContentValues ncv = new ContentValues();
                             var NID = Intent.GetStringExtra("id");
                             ncv.Put("context", edtext.Text);
                             db.Update("NoteBooksql", ncv, " _id = ? ", new string[] { NID.ToString() });
                             var intentAct2 = new Intent(this, typeof(Activity1));
                             StartActivity(intentAct2);
                             Toast.MakeText(this, "已保存", ToastLength.Short).Show();
                             this.Finish();
                         }break;
                    case Android.Resource.Id.Home:
                        {
                            var intent = new Intent(this, typeof(Activity1));
                            StartActivity(intent);
                            this.Finish();
                        } break;
                }
                return true;
            }

    效果图如下

  • 相关阅读:
    用C语言代码实现n进制数转换为十进制数
    RAID简介
    很久没更新自己的博客园的博客了
    微软之于程序员==铁饭碗破了
    sql编译执行过程
    sql server性能终结者锁
    sysprocesses
    SQL SERVER 2008的几个新东西:插入,删除,修改一起来(适合数据的同步)merger
    http Status Code Definitions
    sql server talbe valued parameters (tvp)
  • 原文地址:https://www.cnblogs.com/lihuazou/p/4336984.html
Copyright © 2011-2022 走看看