十天冲刺-09

昨天对详细界面的删除进行了编写,可以通过点击删除按钮跳转删除记录,并显示删除成功,并且跳转至详细项目信息界面

遇到的问题,由于界面跳转时账号信息没有传过来,导致界面闪退

今天学习运用复选框来对数据进行修改

 db = helper_person.getWritableDatabase();
        switch (view.getId())
        {
            case R.id.delete:
            {
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setIcon(android.R.drawable.ic_dialog_info);
                builder.setTitle("温馨提示");
                builder.setMessage("确定要继续吗");
                builder.setCancelable(true);


                builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Log.i("tag","------"+detailed_id+"-----");

                       int count = db.delete("student","id=?",new String[] {String.valueOf(detailed_id)});
                       if(count > 0)
                       {
                           Toast.makeText(detailedactivity.this, "删除成功", Toast.LENGTH_LONG).show();
                           Log.i("tag","------删除成功-----");
                           db.close();
                           Intent intent = new Intent();
                           intent.setClass(detailedactivity.this, loginactivity.class);
                           intent.putExtra("user",account);
                           startActivity(intent);
                       }



                    }
                });

                builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Log.i("tag","------取消-----");
                    }

                });
                builder.create().show();
                break;
            }

  

 

posted on 2019-04-29 07:30  一往无前!  阅读(100)  评论(0编辑  收藏  举报