EditText not restoring state in DialogFragment
I currently have a DialogFragment that has a couple of EditText widgets as part of it's view. When there is an orientation change happens the EditText widgets are not repopulated by the开发者_如何学JAVA text that was in them.
I've looked through the saveInstanceState and the text is being persisted though the orientation change.
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;
}
}
an example EditText:
<EditText
android:text=""
android:id="@+id/loginUsername"
android:layout_width="180dip"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"/>
I am using the android compatibility package.
@CommonsWare I noticed that the AddFeedDialogFragment uses the onCreateDialog method and not the onCreateView method. Perhaps thats the reason the data is properly restored.
精彩评论