[英]EditText not restoring state in DialogFragment
我目前有一個DialogFragment,它有幾個EditText小部件作為它的視圖的一部分。 當發生方向更改時,EditText小部件不會被其中的文本重新填充。
我查看了saveInstanceState,並且通過方向更改保留了文本。
DialogFragment:
public final class LoginDialog extends DialogFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.login, container, false);
return v;
}
}
一個示例EditText:
<EditText
android:text=""
android:id="@+id/loginUsername"
android:layout_width="180dip"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"/>
我正在使用android兼容包。
@CommonsWare我注意到AddFeedDialogFragment使用onCreateDialog方法而不是onCreateView方法。 也許這就是數據正確恢復的原因。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.