Android在运行时获取EditText输入类型 [英] Android Get EditText Input Type At Runtime

查看:68
本文介绍了Android在运行时获取EditText输入类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个编辑文本类的自定义实现.

I have a custom implementation of an edit text class.

基于这些XML属性.....

Based on these XML attribute.....

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

我希望能够在运行时知道这一点(使用Java代码)

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()

这些是根据我上面发布的XML返回的值.

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

97,97,33,129

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?

推荐答案

您得到的数字是十进制数字.例如, textPassword 的十六进制常量为 0x00000081 .当您将其转换为十进制时,它将给出 129 .

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.

这篇关于Android在运行时获取EditText输入类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆