Sana Modi is a technology expert and content writer at nosware. She has a tremendous knowledge of the latest social sites apart from social media, she also examined the latest games and laptops and has personally reviewed the products. She loves to explore all the social media sites and research them.
Last Updated on November 10, 2022 by SanaModi
Sometimes you need to handle Enter button while make an application. To handle button in Kotlin Android Studio, you can just copy this kotlin code.
//Handle Enter Button fun myEnter(){ editText.setOnKeyListener(View.OnKeyListener{v, keyCode, event -> if (keyCode == KeyEvent.KEYCODE_ENTER && event.action == KeyEvent.ACTION_UP){ //Start your action Toast.makeText(this, "Hi there ! \n This is a Enter Event Button", Toast.LENGTH_LONG).show() //End action return@OnKeyListener true } false }) }
How to use, just call:
myEnter()