AlertDialog与ProgessDialog的使用

AlertDialog.Builder dialog=new AlertDialog.Builder(MainActivity.this);
                dialog.setTitle("This is Dialog");//设置标题
                dialog.setMessage("Something important");//设置文本信息
                dialog.setCancelable(false);//能不能按返回键后退
                dialog.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        Toast.makeText(MainActivity.this,"click ok",Toast.LENGTH_SHORT).show();
                        //设置Ok的点击逻辑
                    }
                });
                dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        Toast.makeText(MainActivity.this,"click Cancel",Toast.LENGTH_SHORT).show();
                        //设置Cancel的点击逻辑
                    }
                });
                dialog.show();

  ProgressDialog progressDialog=new ProgressDialog(MainActivity.this);
                progressDialog.setTitle("This is ProgressDialog");
                progressDialog.setMessage("Loading...");
                progressDialog.setCancelable(true);
                progressDialog.show();
posted @ 2017-03-19 23:53  amours  阅读(195)  评论(0编辑  收藏  举报