1
2class MainActivity: AppCompatActivity() {
3
4 override fun onCreate(savedInstanceState: Bundle?) {
5 super.onCreate(savedInstanceState)
6 setContentView(R.layout.activity_message)
7 val editTextMessage = findViewById<EditText>(R.id.myEditeText)
8 showSoftKeyboard(this, editTextMessage)
9 }
10
11
12 private fun showSoftKeyboard(context: Context, v: View) {
13 val iim = context.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
14 if (v.requestFocus()) {
15 iim.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT)
16 }
17 }
18}
19