When the application starts, null is displayed.
I think that I am not correctly assigning a value to the TextView.
class MyFragment : Fragment() {
private lateinit var textView: TextView
companion object {
private val TEXT_FIELD = "text_field"
@JvmStatic
fun newInstance(text_field: Int) = MyFragment().apply {
arguments = Bundle().apply {
putInt(TEXT_FIELD, text_field)
}
}
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.fragment_my, container, false)
textView = view!!.findViewById(R.id.text_view)
textView.text = "${arguments?.getInt(TEXT_FIELD)}"
return view
}
}