Code example for DialogFragment

Methods: setArguments

0
    public static EditNoteDialog newInstance(final String initialNote, EditNoteDialogListener listener) {
        EditNoteDialog dialog = new EditNoteDialog();
 
        Bundle arguments = new Bundle();
        arguments.putString(EditNoteDialog.ARGUMENT_INITIAL_NOTE, initialNote);
        dialog.setArguments(arguments);
        dialog.listener = listener;
 
        return dialog;
    } 
 
    @Override 
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        View view = View.inflate(new ContextThemeWrapper(getActivity(), R.style.dark), R.layout.fragment_edit_note, null);
        mEditText = (EditText) view.findViewById(R.id.note);
        String initialNote = getArguments().getString(ARGUMENT_INITIAL_NOTE);
        if (initialNote != null) {
            mEditText.setText(initialNote);
            getArguments().remove(ARGUMENT_INITIAL_NOTE);
        }