public static ProgressDialog initDialog(Context context) { ProgressDialog progressDialog = new ProgressDialog(context); progressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); progressDialog.setCanceledOnTouchOutside(false); progressDialog.setMessage("loading..."); //使其按下Back键无用 progressDialog.setCancelable(false); //使其点击对话框以外的地方不起作用 progressDialog.setCanceledOnTouchOutside(false); //使其按下Search键无用 progressDialog.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode==KeyEvent.KEYCODE_SEARCH) { return true; } return false; } }); return progressDialog; }