a6b40b247a65fe9fe68ae75625a7a5fb82623f7e
[JavaForFun] /
1 package com.weather.information.fragment;
2
3 import android.app.AlertDialog;
4 import android.app.Dialog;
5 import android.content.DialogInterface;
6 import android.os.Bundle;
7 import android.support.v4.app.DialogFragment;
8
9 public class ErrorDialogFragment extends DialogFragment {
10
11     public static ErrorDialogFragment newInstance(final int title) {
12         final ErrorDialogFragment frag = new ErrorDialogFragment();
13         final Bundle args = new Bundle();
14
15         args.putInt("title", title);
16         frag.setArguments(args);
17
18         return frag;
19     }
20
21     @Override
22     public Dialog onCreateDialog(final Bundle savedInstanceState) {
23         final int title = this.getArguments().getInt("title");
24
25         return new AlertDialog.Builder(this.getActivity())
26         .setIcon(android.R.drawable.ic_dialog_alert)
27         .setTitle(title)
28         .setPositiveButton(android.R.string.ok,
29                 new DialogInterface.OnClickListener() {
30             @Override
31             public void onClick(final DialogInterface dialog,
32                     final int whichButton) {
33
34             }
35         }).create();
36     }
37     
38     @Override
39     public void onDestroyView() {
40         if (getDialog() != null && getRetainInstance()) {
41                 getDialog().setDismissMessage(null);
42         }
43         super.onDestroyView();
44     }
45 }