0

I have my own number keypad. I need edittext but I do not need the keypad. Am doing this project in kotlin. There is an answer here Is there any way to permanently hide soft keyboard but keep enabling focus for an EditText? and also How do you close/hide the Android soft keyboard using Java? however i could not find the code in kotlin. I need code in kotlin . Thanks in advance.

https://snipboard.io/qZ0fYW.jpg i copied Java code and Android Studio converted it to java but it failed and giving error.

2 Answers2

0

You have to either do:

calcET.setOnClickListener(object: View.OnClickListener {
            override fun onClick(v: View?) {
                //code here
            }

        })

notice the brackets are removed and the override keyword added

or simply:

calcET.setOnClickListener {
            //code here
        }
Nongthonbam Tonthoi
  • 11,055
  • 6
  • 30
  • 59
0

You can use the below extension to hide Keyboard

 fun Activity.hideKeyboard() {
     val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as 
     InputMethodManager 
     imm.hideSoftInputFromWindow(findViewById<View>. 
     (android.R.id.content).windowToken,0) 
 }
Subham Naik
  • 307
  • 3
  • 9