androidandroid-edittextandroid-inputtype

Android Get EditText Input Type At Runtime


I have a custom implementation of an edit text class.

Based on these XML attribute.....

android:inputType="textPersonName"
android:inputType="textPersonName"
android:inputType="textEmailAddress"
android:inputType="textPassword"

I want to be able to know this at run time (In Java Code)

I have found this method which gives me the input type

getInputType()

And these are the values returned based on the XML I posted above.

97,97,33,129

However, these do not correspond to the constant values listed here

http://developer.android.com/reference/android/text/InputType.html

How can I know the input type of an edit text at run time?


Solution

  • The numbers you are getting are decimal numbers.For example textPassword has constant value 0x00000081 in hex.When you convert that in decimal it will give 129.

    Hence the output you are getting is perfect.

    Refer this to find the list of all input-types with their hex values.