Home > Software design >  The program crashes when I convert String to Int in Edittext
The program crashes when I convert String to Int in Edittext

Time:08-18

package com.example.testapp

import android.os.Bundle
import android.widget.EditText
import androidx.appcompat.app.AppCompatActivity
import com.example.testapp.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {
    lateinit var binding: ActivityMainBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)
    }

    override fun onResume() {
        super.onResume()
        binding.btplus.setOnClickListener {
            val text:String = binding.editText0.text.toString()
                       
  • Related