Code example for DialogFragment

Methods: onCreate, setRetainInstance

0
		return destroyed;
	} 
 
	@Override 
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
 
		// Retain instance so that it survives orientation changes 
		setRetainInstance(true);
	} 
 
	@Override 
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		dialog = new ProgressDialog(this.getActivity());
		dialog.setTitle(getArguments().getString("title"));
		dialog.setMessage(getArguments().getString("message"));
		dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
		dialog.setIndeterminate(true);
		dialog.setOnCancelListener(new OnCancelListener() {
			public void onCancel(DialogInterface dialog) {
Experience pair programming with AI  Get Codota for Java