edittext 手机号、邮箱输入限制、禁止输入--binbinyang
来源:互联网 发布:淘宝店铺页头怎么添加 编辑:程序博客网 时间:2024/06/05 20:07
今天是2017年1月.真快..就快过年了...说说最近写的代码吧...因为最近做的APP一直类似于OA 钉钉类,所以会去判断输入的文本框,同样会给与限制
public class EdittextDemoActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_edittextdemo);/** * 只能输入数字 */ EditText mEtNum = (EditText) findViewById(R.id.et_num); mEtNum.setInputType(InputType.TYPE_CLASS_NUMBER);/** * 只能输入电话号码 */ EditText mEtTell = (EditText) findViewById(R.id.et_tell); mEtTell.setInputType(InputType.TYPE_CLASS_PHONE);//电话 /** * 邮箱地址 */ EditText mEtEmail = (EditText) findViewById(R.id.et_email); mEtEmail.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); /** * 禁止输入任何文本 * */ EditText mEtBan = (EditText) findViewById(R.id.et_ban); mEtBan.setInputType(InputType.TYPE_NULL); /** * // 禁止输入(不弹出输入法)上述也是隐藏输入法的一种方式,还有另外一种隐藏办法, */ EditText mEtBan_other = (EditText) findViewById(R.id.et_ban2); mEtBan_other.setInputType(InputType.TYPE_NULL); Toast.makeText(EdittextDemoActivity.this, "焦点改变", Toast.LENGTH_SHORT).show(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);//第一种方法//imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS);//第二种方法 imm.hideSoftInputFromWindow(mEtBan_other.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); }}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#fff" android:orientation="vertical" android:padding="20dp"> <EditText android:id="@+id/et_num" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="1"/> <EditText android:id="@+id/et_tell" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="2"/> <EditText android:id="@+id/et_email" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="3"/> <EditText android:id="@+id/et_ban" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="4"/> <EditText android:id="@+id/et_ban2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="5"/></LinearLayout>
0 0
- edittext 手机号、邮箱输入限制、禁止输入--binbinyang
- EditText限制输入字数,并且禁止输入表情符号
- EditText输入限制:整数,小数,最大值,最大字符长度,手机号
- android EditText怎样限制用户的输入?数字/字母/邮箱
- EditText禁止输入中文
- edittext禁止输入表情
- EditText禁止输入表情
- EditText禁止输入表情
- EditText禁止输入表情符号
- EditText中禁止输入中文的方法及长度限制
- Edittext输入手机号进行格式化
- 手机号空格输入的EditText
- editText限制输入字符长度,禁止输入表情,清除输入文字的按钮
- EditText输入限制setFilters
- EditText限制文字输入
- EditText限制输入长度
- EditText限制输入字数
- 限制EditText输入字数
- 深入源码看数据结构--集合和Map底层实现
- leetcode 160 Intersection of Two Linked Lists
- linux統一设备模型
- $('div','li') 和 $('div , li') 和 $('div li') 区别
- SSH免密码设置
- edittext 手机号、邮箱输入限制、禁止输入--binbinyang
- spring-mvc框架下载
- Maven版本校验 Version Range的支持
- Ubuntu16.10 下安装node.js提示./configure 权限不够的解决方法
- Myeclipse将控制台日志输出到文件中和显示更多的日志信息
- Activiti 自定义事件监听和邮件通知
- Leetcode——36. Valid Sudoku
- Mysql事务以及加锁机制事务的特征ACID
- 类成员函数作为线程函数使用