Dialogfragment - Setting Initial Values And Retaining State After Rotation
I have created an DialogFragment which is building and returning AlertDialog from onCreateDialog method. The AlertDialog contains two EditText views. I'm setting the initial value
Solution 1:
Calendar
is Serializable
so you can put it as that in the Bundle
.
Solution 2:
You can store your data in onSaveInstanceState(Bundle outState) method, and read them again in onRestoreInstanceState() method. onSaveInstanceState will be called before screen rotation, and onRestoreInstanceState() after change. This is a good place to store data between orientation changes.
Or you can also add in Manifest file
android:configChanges="orientation"
Add this value to activitiy, which contains your alertDialog.
Post a Comment for "Dialogfragment - Setting Initial Values And Retaining State After Rotation"