Code example for DialogFragment

Methods: show, setArguments

0
 
    public static final MessageDialogFragment showMessage(FragmentManager fm, CharSequence message) {
        Bundle args = new Bundle(1);
        args.putCharSequence(ARG_MESSAGE, message);
        MessageDialogFragment frag = new MessageDialogFragment();
        frag.setArguments(args);
        frag.show(fm, TAG);
        return frag;
    } 
 
    @Override 
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        return new AlertDialog.Builder(getActivity())
                .setPositiveButton(android.R.string.ok, null)
                .setMessage(getArguments().getCharSequence(ARG_MESSAGE))
                .create();
    } 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE