Home > OS >  How to listen to Androids Soft Keyboard clear button when pressed?
How to listen to Androids Soft Keyboard clear button when pressed?

Time:08-20

I would like to know how can I listen for the android soft keyboard clear button in my activity Kotlin class, so when the clear button is pressed I need to do something.

Thanks

CodePudding user response:

You can do it with setOnKeyListener()

editText.setOnKeyListener { v, keyCode, event ->
            if(event.action == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_DEL){
                // on clear do something
            }
            
            false
        }
    
  • Related