Code example for DialogFragment

Methods: setArguments, setCancelable

0
    } 
 
    public static MagicWordDialog newInstance() { 
        MagicWordDialog frag = new MagicWordDialog();
        Bundle args = new Bundle();
        frag.setArguments(args);
        frag.setCancelable(false);
        return frag;
    } 
 
    @Override 
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        LayoutInflater factory = LayoutInflater.from(getActivity());
        final View magicWordView = factory.inflate(R.layout.magic_word_dialog, null);
        magicWordText = (EditText) magicWordView.findViewById(R.id.password_edit);
        magicWordText.setOnEditorActionListener(this);
        return new AlertDialog.Builder(getActivity())
            .setIcon(android.R.drawable.ic_dialog_alert)
            .setTitle(R.string.magic_word_dialog_title)
            .setView(magicWordView)
            .setPositiveButton(R.string.alert_dialog_ok,this)