Android Kotlin TextWatcher Usage

Usage of Text Watcher in Kotlin | Android Studio
package com.googlecraft.textwatcher

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.widget.Button
import android.widget.EditText

class MainActivity : AppCompatActivity() {
lateinit var inputtext :EditText
lateinit var action_button: Button

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

inputtext=findViewById(R.id.textinput)
action_button=findViewById(R.id.button)


inputtext.addTextChangedListener(object : TextWatcher
{
override fun afterTextChanged(p0: Editable?) {
}

override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
}

override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
action_button.isEnabled=true
}

})

}
}

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *