当用户单击注册按钮时,会出现一个自定义对话框并且用户移动到菜单。但在我的例子中,服装对话框只出现一秒钟,然后用户进入下一个布局。
请问如何设置自定义对话框的时间?
这是我的代码:
buttonRegister.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
new Thread(new Runnable() {
@Override
public void run() {
final String name = inputName.getText().toString();
final String mail = inputEmail.getText().toString();
final String password = inputPassword.getText()
.toString();
PatientFunctions patientFunction = new PatientFunctions();
json = patientFunction.registerPatient(name, mail,
password);
try {
if (json.getString(KEY_SUCCESS) != null) {
String res = json.getString(KEY_SUCCESS);
if (Integer.parseInt(res) == 1) {
Intent main = new Intent(
getApplicationContext(), Main.class);
main.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(main);
finish();
}
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
catch (JSONException e) {
e.printStackTrace();
}
}
}).start();
CustomizeDialog customizeDialog = new CustomizeDialog(RegisterPatient.this);
customizeDialog.show();
Handler handler = null;
handler = new Handler();
handler.postDelayed(new Runnable(){
public void run(){
customizeDialog.cancel();
customizeDialog.dismiss();
}
}, 3000);
}
});