lateinit var name: String override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) button.setOnClickListener { name = editText.text.toString()} } override fun onSaveInstanceState(outState: Bundle) { outState.putString("name", name) super.onSaveInstanceState(outState) } }