先看下源码
/**
* Controls whether the saving of this view's state is
* enabled (that is, whether its {@link #onSaveInstanceState} method
* will be called). Note that even if freezing is enabled, the
* view still must have an id assigned to it (via {@link #setId(int)})
* for its state to be saved. This flag can only disable the
* saving of this view; any child views may still have their state saved.
*
* @param enabled Set to false to <em>disable</em> state saving, or true
* (the default) to allow it.
*
* @see #isSaveEnabled()
* @see #setId(int)
* @see #onSaveInstanceState()
* @attr ref android.R.styleable#View_saveEnabled
*/
public void setSaveEnabled(boolean enabled) {
setFlags(enabled ? 0 : SAVE_DISABLED, SAVE_DISABLED_MASK);
}
/**
*控制是否保存此视图的状态
*已启用(即其{@link#onSaveInstanceState}方法
*将被调用)。请注意,即使启用了冻结,也会
*视图仍然必须有一个分配给它的id(通过{@link#setId(int)})
*用于保存其状态。此标志只能禁用
*保留这一观点;任何子视图都可能仍保存其状态。
*
*@param enabled设置为false以禁用状态保存,或设置为true
*(默认值)以允许它。
*
*@see#isSaveEnabled()
*@see#setId(int)
*@see#onSaveInstanceState()
*@attr ref android.R.styleable#View_saveEnabled
*/
DialogFragment中存在EditText,从外部传值进去设置时,需要添加代码EditText.setSaveEnabled(false);