Android software keyboard switch between numeric and alphabetic programmatically

前端 未结 3 1368
被撕碎了的回忆
被撕碎了的回忆 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 02:56

    you can achieve it by setting the below attribute to EditText on xml has follows android:inputType="number"

    0 讨论(0)
  • 2021-02-19 03:03

    I find the answer a day, finally I found this and its work.

    android:inputType="textVisiblePassword"
    

    source

    0 讨论(0)
  • 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);
    
    0 讨论(0)
提交回复
热议问题