我希望我的活动(显示对话)在用户单击对话的正面按钮时完成。这可能吗。我在哪里放置finish()?
调用对话的代码:
if(name.equals("")) {
DialogFragment newFragment = new NouserFragment();
newFragment.show(getFragmentManager(), "makeprofile"); }
对话代码:
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the Builder class for convenient dialog construction
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(R.string.nouseralert)
.setPositiveButton(R.string.add, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent intent = new Intent(getActivity(), Editprofile.class);
startActivityForResult(intent, 0);
}
})
.setNegativeButton(R.string.ignore, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User cancelled the dialog
}
});
// Create the AlertDialog object and return it
return builder.create();
}