The documentation says:
clicked button (ex. BUTTON_POSITIVE) or clicked on
Once you are inherited, is this some kind of custom dialog? It is unlikely that this interface will receive an ID from a custom button. Just find the button and ask her the right listener.
UPD Yes, I understood you, but you connected the custom button through the markup, though I don’t know if it can be said that way: D
The bottom line is that in the usual dialog box there are three buttons - positive, negative and neutral. Well, something like OK - CANCEL ... You can specify them:
public class FireMissilesDialogFragment extends DialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(R.string.dialog_fire_missiles) .setPositiveButton(R.string.fire, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // FIRE ZE MISSILES! } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog } }); // Create the AlertDialog object and return it return builder.create(); }
And instead of specifying the listeners immediately for such buttons, you can implement the interface that you wrote. And then the onClick method in the variable which will receive one of the three constants - BUTTON_NEGATIVE, BUTTON_NEUTRAL or BUTTON_POSITIVE. Further, I think it is clear. Related links - https://developer.android.com/guide/topics/ui/dialogs.html , https://developer.android.com/reference/android/content/DialogInterface.html#BUTTON_POSITIVE