how to hide keyboard in android fragment kotlin code example
Example 1: hide keyboard suggestion android kotlin
android:inputType="textVisiblePassword"
OR
EdtiText editTextBox = findViewById(R.id.myEditTextView);
editTextBox.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
Example 2: hide keyboard android kotlin
class CloseHideSoftKeyboard : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_message)
val editTextXml = findViewById<EditText>(R.id.editText)
val btnSendMessage = findViewById<Button>(R.id.btnSend)
btnSendMessage.setOnClickListener{
closeSoftKeyboard(this, editTextXml)
}
}
private fun closeSoftKeyboard(context: Context, v: View) {
val iMm = context.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
iMm.hideSoftInputFromWindow(v.windowToken, 0)
v.clearFocus()
}
}