This DialogFragment implementation causes an
IllegalStateException( \"You can not set Dialog\'s OnCancelListener or OnDismissListener\")
Try this code i hope this will be work..
AlertDialog.Builder builder = new AlertDialog.Builder(
class_name.this);
builder.setTitle("Title");
AlertDialog dialog = builder.create();
dialog.setButton("ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
});
dialog.setButton2("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
dialog.show();