Code example for Fragment

Methods: getId

0
	private static final String ARG_CANCELABLE = "cancleable";
	 
	private boolean cancelable = false;
	 
	public static ConnectionErrorFragment newInlineError(Fragment parent) {
		if (parent.getId() == 0) {
			throw new IllegalArgumentException("parent does not show a view");
		} 
		 
		ConnectionErrorFragment fragment = new ConnectionErrorFragment();
		fragment.setTargetFragment(parent, 0);
		 
		return fragment;
	} 
	 
	public static ConnectionErrorFragment newDialogError(Fragment parent, int requestCode, boolean cancelable) {
		Bundle args = new Bundle();
		args.putBoolean(ARG_CANCELABLE, cancelable);
		 
		ConnectionErrorFragment fragment = new ConnectionErrorFragment();
		fragment.setTargetFragment(parent, requestCode);