Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 290
Ersen Osman Avatar asked Sep 09 '15 11:09

Ersen Osman


People also ask

How to set input type in EditText Android Programmatically?

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.

What is InputType in Android?

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.

Which attribute of EditText tells the system keyboard what kind of input you are expecting?

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.


1 Answers

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.

like image 180
kgandroid Avatar answered Sep 29 '22 13:09

kgandroid