Answer the question
In order to leave comments, you need to log in
After leaving the fragment to the previous fragment and changing the orientation, the editText must not be null?
java.lang.IllegalStateException: fah_edtFname must not be null
From Fragment A I press the button and Fragment B opens, in it I save the values of all EditText' s, when I flip the screen, everything typed is saved, but as soon as I return to Fragment A and change orientation screen, the error java.lang.IllegalStateException: fah_edtFname must not be null, (fah_edtFname is EditText), that is, if I go to Fragment B, then press the back arrow and it returns me to the previous Fragment A, and press change orientation, then being in fragment A, I get an error that in the closed fragment B, my edit texts are null ..
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
val human = saveChangedText()
outState.putParcelable("savedText",human)
}
fun saveChangedText():Human?{
val firstName = fah_edtFname.text.toString()
val lastName=fah_edtLastName.text.toString()
val age =fah_edtAge.text.toString()
val job = fah_edtJob.text.toString()
return Human(first_name = firstName,last_name = lastName,age = age,job = job)
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question