Android输入法 监听事件
登录界面有一个输入用户名和密码的编辑框:
private EditText et_userName;// 账户
private EditText et_password;// 密码
布局文件如下:
<EditText
android:id="@+id/login_et_username"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@null"
android:drawableLeft="@drawable/account_icon"
android:drawablePadding="7dp"
android:hint="@string/login_num"
android:paddingLeft="15dp"
android:singleLine="true"
android:textColor="@android:color/white"
android:textColorHint="@color/login_frame_hint_color"
android:textSize="20sp" /> <EditText
android:id="@+id/login_et_userpassword"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="@null"
android:drawableLeft="@drawable/password_icon"
android:drawablePadding="7dp"
android:hint="@string/login_password"
android:inputType="textPassword"
android:imeOptions="actionGo"
android:paddingLeft="15dp"
android:singleLine="true"
android:textColor="@android:color/white"
android:textColorHint="@color/login_frame_hint_color"
android:textSize="20sp" />
Acvity中实现监听输入法回车键执行登录操作:
//密码文本框的监听
et_password.setOnEditorActionListener(new OnEditorActionListener() { @Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
//判断action为GO执行的操作
if(actionId == EditorInfo.IME_ACTION_GO){
InputMethodManager imm = (InputMethodManager) v
.getContext().getSystemService(
Context.INPUT_METHOD_SERVICE);
if (imm.isActive()) {
imm.hideSoftInputFromWindow(
v.getApplicationWindowToken(), 0);
}
//执行登录方法,提交表单操作。
return true;
}
return false;
}
});
Android输入法 监听事件的更多相关文章
- android editText 监听事件
在软键盘中注意 在监听的 edittext中 使用android:imeOptions属性的时候,一定要对EditText设置 android:inputType 或者 设置 android:sing ...
- Android onclick监听事件打开新界面
一.新建工程 二.新建XML代码 新建一个Button <Button android:layout_width="wrap_content" android:layout_ ...
- android EditText监听事件及参数详解
editText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence ...
- android典型监听事件实
public class MainActivity extends Activity { int counter; Button add, sub; TextView display; @Overri ...
- xamarin android如何监听单击事件
在xamarin android单击事件是最基础的事情,看过菜鸟上的android教程时,java写的都是监听事件,为一个按钮,单选按钮.多选按钮的单击事件有三种,前面两种用的非常普遍,也很简易,我这 ...
- Android中Button的五种监听事件
简单聊一下Android中Button的五种监听事件: 1.在布局文件中为button添加onClick属性,Activity实现其方法2.匿名内部类作为事件监听器类3.内部类作为监听器4.Activ ...
- Android如何监听蓝牙耳机的按键事件
写在前面: 直接想要代码很简单,你直接把滚动条拉到最底端就可以看到.如果想要十分地了解为什么,那就按照我规划的一步一步来理解.以下测试环境以手头上有的「Bluedio + 红米手机」. 1.蓝牙耳机的 ...
- 一步一步学android之事件篇——单选按钮监听事件
在平常使用软件的时候,我们经常会碰见一些选择题,例如选择性别的时候,在男和女之间选,前面说过这个情况要用RadioGroup组件,那么点击了之后我们该怎么获取到选择的那个值呢,这就是今天要说的OnCh ...
- Android如何监听蓝牙耳机的按键事件(转)
源: Android如何监听蓝牙耳机的按键事件 写在前面: 直接想要代码很简单,你直接把滚动条拉到最底端就可以看到.如果想要十分地了解为什么,那就按照我规划的一步一步来理解.以下测试环境以手头上有的「 ...
随机推荐
- Linux下安装oracle11g
1.安装环境: Linux:Redhat Enterprise Linux 6.3 64位 Oracle:Oracle Database 11g for Linux x86-64 64位 2.修改操作 ...
- Hibernate 关联关系映射实例
双向多对一/一对多(many-to-one/one-to-many) 例子,多个学生对应一个班级,一个班级对应多个学生: 班级类,Grade.java: public class Grade { pr ...
- JSP基础之 C标签中的 varStatues属性
变量状态参数,该属性有5个常用值count 表示当前遍历集合的元素个数index 表示当前遍历到集合的第几个元素current 表示当前的集合元素first 表示集合的第一个元素last 表示集合的最 ...
- python 基础篇(二)数据类型概述
正式进入python的学习. 数据类型可以分为身份,类型,数据项三项联合组成. 身份: id() 类型:type() 数据类型:int,boolean,tuple,string,dict,list 1 ...
- [Effective Modern C++] Item 2. Understand auto type deduction - 了解auto类型推断
条款二 了解auto类型推断 基础知识 除了一处例外,auto的类型推断与template一样.存在一个直接的从template类型推断到auto类型推断的映射 三类情况下的推断如下所示: // ca ...
- vb的property 和event
Event 语句 定义用户自定义的事件. 语法 [Public] Event procedurename [(arglist)] Event 语句包含下面部分: 部分 描述 Public 可选的.指定 ...
- 调试 JavaScript 脚本
随着 JavaScript 应用的复杂性逐渐提高,开发者需要有力的调试工具来帮助他们快速发现问题的原因,并且能高效地修复它.Chrome DevTools 提供了一系列实用的工具使得调试 JavaSc ...
- YUV422 YUV420 Planar \ Semi-Planar \ Interleaved
关于yuv 格式 YUV 格式通常有两大类:打包(packed)格式和平面(planar)格式.前者将 YUV 分量存放在同一个数组中,通常是几个相邻的像素组成一个宏像素(macro-pixel);而 ...
- Wordpress主题中常用代码总结
1. 在 Wordpress主题中显示最热文章的 PHP代码 <?php $result = $wpdb->get_results("SELECT comment_count,I ...
- Oracle EBS-SQL (CST-2):检查有BOM但成本不基于累积的数据.sql
select c.segment1 物料编码, ...