Android Get EditText Input Type At Runtime

前端 未结 3 788
星月不相逢
星月不相逢 2021-01-05 13:48

I have a custom implementation of an edit text class.

Based on these XML attribute.....

android:inputType=\"textPersonName\"
android:inputType=\"text         


        
3条回答
  •  广开言路
    2021-01-05 14:03

    How to get the InputType from an EditText

    To get the input type use getInputType().

    int inputTypeValue = editText.getInputType();
    

    The InputType values are defined (in hexadecimal) in the documentation.

    You can test the values with something like

    if (inputTypeValue == InputType.TYPE_CLASS_TEXT) { ... }
    

    See also

    • Setting the InputType

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题