The code
button can be found within the view inflated from the release_scan_dialog
layout.
public class ScanFragment extends DialogFragment {
public android.app.Dialog onCreateDialog(android.os.Bundle savedInstanceState) {
// Inflate the view for the release_scan_dialog layout.
final View release_scan_view = getActivity().getLayoutInflater().inflate(R.layout.release_scan_dialog, null);
AlertDialog dialog = new AlertDialog.Builder(this.getActivity())
.setView(release_scan_view)
.setTitle(R.string.title_store)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
})
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
})
.create();
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
}
});
// Set the OnClickListener for the 'code' button in the release_scan_dialog layout.
release_scan_view.findViewById(R.id.code).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
((AlertDialog) getDialog()).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
}
});
return dialog;
}
}