我有这段代码:
AlertDialog.Builder builder = new AlertDialog.Builder(activity.this);
builder.setMessage("Message")
.setTitle("Title");
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
});
AlertDialog dialog = builder.create();
dialog.show();
Intent intent = new Intent(this, Menu.class);
startActivity(intent);
finish();
但它显示第二个AlertDialog并切换到另一个活动。如何让它等待点击PositiveButton?
答案 0 :(得分:0)
AlertDialog.Builder builder = new AlertDialog.Builder(activity.this);
builder.setMessage("Message")
.setTitle("Title");
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent intent = new Intent(this, Menu.class);
startActivity(intent);
finish();
}
});
AlertDialog dialog = builder.create();
dialog.show();