Android software keyboard switch between numeric and alphabetic programmatically

前端 未结 3 1364
被撕碎了的回忆
被撕碎了的回忆 2021-02-19 02:31

I have an EditText with inputMode = text. By default software keyboard is shown as alphabetical and user have to switch it to numeric by pressing specific key (

3条回答
  •  庸人自扰
    2021-02-19 03:05

    Just set it with the normal setter:

        EditText editText = (EditText) findViewById(R.id.edittext);
        editText.setInputType(InputType.TYPE_CLASS_NUMBER);
        // or 
        editText.setInputType(InputType.TYPE_CLASS_TEXT);
    

提交回复
热议问题