EditText does not restore state in DialogFragment

I currently have a DialogFragment that has a couple of EditText widgets as part of this view. When a change in orientation occurs, the EditText widgets are not populated by the text that was in them.

I looked at the saveInstanceState file and the text is saved, although the orientation is changed.

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 example:

 <EditText android:text="" android:id="@+id/loginUsername" android:layout_width="180dip" android:layout_height="wrap_content" android:layout_marginRight="5dip"/> 

I am using an Android compatibility pack.

+6
source share
1 answer

@CommonsWare I noticed that AddFeedDialogFragment uses the onCreateDialog method, not the onCreateView method. Perhaps that is why the data is correctly restored.

0
source

Source: https://habr.com/ru/post/887435/


All Articles