Android键盘EditText只允许输入数字和英文
主要要使用一个正则过滤即可实现:
String regular = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
mXEditText.setKeyListener(new DigitsKeyListener() {
@Override
public int getInputType() {
return InputType.TYPE_TEXT_VARIATION_PASSWORD;
}
@Override
protected char[] getAcceptedChars() {
char[] ac = regular.toCharArray();
return ac;
}
});

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
-
上一篇
Android--代码实现自定义Button
版权声明:本文为博主原创文章,转载请标明出处。 https://blog.csdn.net/chaoyu168/article/details/80350654 使用StateButton.java,res/values/attrs.xml import android.content.Context; import android.content.res.ColorStateList; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.StateListDrawable; import android.support.annotation.ColorInt; import android.support.annotation.FloatRange; import android.support.annota...
-
下一篇
Android 开发 常用工具类收藏(随时更新)
说在前面,以下工具类可以大大的提高安卓开发者的开发效率 1、偏好设置(ShareUtils) import android.content.Context; import android.content.SharedPreferences; /** * Content:偏好设置工具类 * Actor:韩小呆 ヾ(゚▽゚)ノ * Time: 15:44 */ public class ShareUtils { public static final String NAME = "config.hxd"; /** * 存入数据(String) */ public static void putString(Context context, String key, String value) { //获得偏好设置 SharedPreferences spf = context.getSharedPreferences(NAME, Context.MODE_PRIVATE); //向偏好设置内部添加数据并且提交 spf.edit().putString(key, value).apply();...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- Docker容器配置,解决镜像无法拉取问题
- Docker快速安装Oracle11G,搭建oracle11g学习环境
- 2048小游戏-低调大师作品
- SpringBoot2编写第一个Controller,响应你的http请求并返回结果
- SpringBoot2初体验,简单认识spring boot2并且搭建基础工程
- Docker使用Oracle官方镜像安装(12C,18C,19C)
- SpringBoot2整合MyBatis,连接MySql数据库做增删改查操作
- MySQL数据库在高并发下的优化方案
- Dcoker安装(在线仓库),最新的服务器搭配容器使用
- CentOS7编译安装Cmake3.16.3,解决mysql等软件编译问题