private Dialog mDialog;
public void showRoundProcessDialog(final Context mContext, int layout) {
OnKeyListener keyListener = new OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode,
KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
Toast.makeText(mContext, "back", 1).show();
//在这个地方可以停掉线程之类的操作
}
return false;
}
};
mDialog = new AlertDialog.Builder(mContext).create();
mDialog.setOnKeyListener(keyListener);
mDialog.show();
// 注意此处要放在show之后 否则会报异常
mDialog.setContentView(layout);
}