当前位置:首页 » 安卓系统 » android只能输入数字

android只能输入数字

发布时间: 2024-03-17 15:44:58

‘壹’ android 如何用代码实现EditText控件中只能输入数字

数字<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number" />
带小数的数字 <EditText
android:id="@+id/editText3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal" />
电话号码的 <EditText
android:id="@+id/editText4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="phone" />

‘贰’ Android EditeText 只能输入数字与字母的组合 应该怎么写(详细点的)

可以在EditText中设置属性。

android:numeric="integer"即只能输入整数,如<EditText

android:id="@+id/home_et_validate"

style="@style/order_vcode_input"

android:hint="请输入订单验证码"

android:inputType="number"

android:digits="@string/filter_vcode"/>

<string name="filter_vcode"></string>

这样就可以了。

‘叁’ android 中怎么控制EditText只能输入数字和字母,不能有汉字,字符

例子如下:
strings.xml文件:
<string name="rule_password">`¬!"£$%^*()~=#{}[];':,./?/*-_+<>@&</string>
EditText的布局文件:

<EditText android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:digits="@string/rule_password"/>
注:在strings.xml中不能直接写特殊符号,如@&等特殊符号,可使用ASCII码表示。
<的ASCII码为 <
>的ASCII码为 >

@的ASCII码为 @
&的ASCII码为 &

‘肆’ Android EditText只能输入两位小数,如:金额,钱等

1、设置输入类型

2、添加addTextChangedListener

3、EditTextUtil

热点内容
苹果传输安卓机视频怎么不压缩 发布:2025-09-18 14:53:43 浏览:676
sql页面 发布:2025-09-18 14:51:08 浏览:946
无法访问移动硬盘参数错误 发布:2025-09-18 14:50:15 浏览:542
exist数据库 发布:2025-09-18 14:42:36 浏览:655
白百何访问 发布:2025-09-18 14:20:14 浏览:456
人人贷源码 发布:2025-09-18 14:11:02 浏览:995
pythonlist删除list 发布:2025-09-18 14:03:29 浏览:247
我的世界服务器手机版新手 发布:2025-09-18 13:51:33 浏览:836
php从入门到精通下载 发布:2025-09-18 13:36:44 浏览:164
抖音使用脚本 发布:2025-09-18 13:29:36 浏览:812