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 OpenSansEditText editText = (OpenSansEditText) 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); 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 (getActivity() instanceof Callback) { ((Callback) getActivity()).onSuccessfulInput(editText.getText().toString()); } else { String error = getActivity() + "is not an instance of ProfileInputDialogFragment Callback"; AppLog.e(AppLog.T.UTILS, error); } } }) .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 OpenSansEditText editText = (OpenSansEditText) 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 (getActivity() instanceof Callback) { ((Callback) getActivity()).onSuccessfulInput(editText.getText().toString(), callbackId); } else { String error = getActivity() + "is not an instance of ProfileInputDialogFragment Callback"; AppLog.e(AppLog.T.UTILS, error); } } }) .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); return alertDialogBuilder.create(); }