I'm trying to implement ProgressDialog in DialogFragment and use it as a Fragment. My onCreateDialog looks like this:
public Dialog onCreateDialog(Bundle savedInstanceState) {
String message = getArguments().getString("msg");
ProgressDialog dialog = new ProgressDialog(getActivity());
dialog.setMessage(message);
dialog.setTitle("");
dialog.setCancelable(true);
dialog.setIndeterminate(true);
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
return dialog;
}
According to android developers, to use this dialog as a Fragment, I must implement onCreateView, which returns view object. The question is, how do I get View of such dialog?
It works with just the onCreateDialog. If you want to create a more complex view and fragment, you should create a method such as:
public View onCreateView( . .. ) {
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.fragment_xml_id, null);
return view;
}
See this blog for more: http://android-developers.blogspot.com/2012/05/using-dialogfragments.html