Check if EditText is empty kotlin android


Ask A Question





Login To post a question

How do you check if an EditText is empty? input type number

package com.example.www.myapplication

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
import java.util.*

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
    button.setOnClickListener {

        val inter:Int=editText.text.toString().toInt()
        val year: Int = Calendar.getInstance().get(Calendar.YEAR)
        val res:Int=year-inter
        textView.text=res.toString()
    }
}

For more info please click herehttps://stackoverflow.com/q/46035877



Have a question or need a custom quote?
info@smartinfocare.com