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?
This example demonstrates how to set the input type for an Android EditText programmatically using Kotlin. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.
The android:inputType attribute allows you to specify various behaviors for the input method. Most importantly, if your text field is intended for basic text input (such as for a text message), you should enable auto spelling correction with the "textAutoCorrect" value.
Setting the InputType of an EditText tells the system keyboard what kind of input you are expecting. If your edit text is for inputting a phone number, then you want the keyboard to show numbers.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With