Source:
public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater layoutInflater = LayoutInflater.from(getActivity()); View promptView = layoutInflater.inflate(R.layout.my_profile_dialog, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity()); alertDialogBuilder.setView(promptView); final WPTextView textView = (WPTextView) promptView.findViewById(R.id.my_profile_dialog_label); final WPEditText editText = (WPEditText) promptView.findViewById(R.id.my_profile_dialog_input); final WPTextView hintView = (WPTextView) promptView.findViewById(R.id.my_profile_dialog_hint); Bundle args = getArguments(); String title = args.getString(TITLE_TAG); String hint = args.getString(HINT_TAG); Boolean isMultiline = args.getBoolean(IS_MULTILINE_TAG); String initialText = args.getString(INITIAL_TEXT_TAG); final int callbackId = args.getInt(CALLBACK_ID_TAG); textView.setText(title); if (!TextUtils.isEmpty(hint)) { hintView.setText(hint); } else { hintView.setVisibility(View.GONE); } if (!isMultiline) { editText.setMaxLines(1); } if (!TextUtils.isEmpty(initialText)) { editText.setText(initialText); editText.setSelection(0, initialText.length()); } alertDialogBuilder.setCancelable(true) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { if (mCallback != null) { mCallback.onSuccessfulInput(editText.getText().toString(), callbackId); } } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); return alertDialogBuilder.create(); }

Target:
public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater layoutInflater = LayoutInflater.from(getActivity()); View promptView = layoutInflater.inflate(R.layout.my_profile_dialog, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity()); alertDialogBuilder.setView(promptView); final WPTextView textView = (WPTextView) promptView.findViewById(R.id.my_profile_dialog_label); final WPEditText editText = (WPEditText) promptView.findViewById(R.id.my_profile_dialog_input); final WPTextView hintView = (WPTextView) promptView.findViewById(R.id.my_profile_dialog_hint); Bundle args = getArguments(); String title = args.getString(TITLE_TAG); String hint = args.getString(HINT_TAG); Boolean isMultiline = args.getBoolean(IS_MULTILINE_TAG); String initialText = args.getString(INITIAL_TEXT_TAG); final int callbackId = args.getInt(CALLBACK_ID_TAG); textView.setText(title); if (!TextUtils.isEmpty(hint)) { hintView.setText(hint); } else { hintView.setVisibility(View.GONE); } if (!isMultiline) { editText.setMaxLines(1); } if (!TextUtils.isEmpty(initialText)) { editText.setText(initialText); editText.setSelection(0, initialText.length()); } alertDialogBuilder.setCancelable(true) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { if (getTargetFragment() instanceof Callback) { ((Callback) getTargetFragment()).onSuccessfulInput(editText.getText().toString(), callbackId); } else { AppLog.e(AppLog.T.UTILS, "Target fragment doesn't implement ProfileInputDialogFragment.Callback"); } } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); return alertDialogBuilder.create(); }