what is wrong with that code?
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.randomButton.setOnClickListener {
findNavController().navigate(R.id.action_FirstFragment_to_SecondFragment)
}
view.findViewById<Button>(R.id.toast_button).setOnClickListener {
val myToast = Toast.makeText(context, "Hello Toast!", Toast.LENGTH_SHORT)
myToast.show()
}
view.findViewById<Button>(R.id.count_button).setOnClickListener {
countMe(view)
}
}
private fun countMe(view: View) {
val showCountTextView = view.findViewById<TextView>(R.id.textview_first)
val countString = showCountTextView.text.toString()
var count = countString.toInt()
count++
showCountTextView.text = count.toString()
}
Im doing 'Build Your First Android App in Kotlin' [ https://developer.android.com/codelabs/build-your-first-android-app-kotlin#7 ] tutorial and app is crashing when i press random button on device. There is no crash when i delete those 3 lines
var count = countString.toInt()
count++
showCountTextView.text = count.toString()
but ofc it doesnt solve the problem.