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如何监听蓝牙耳机的按键事件 写在前面: 直接想要代码很简单,你直接把滚动条拉到最底端就可以看到.如果想要十分地了解为什么,那就按照我规划的一步一步来理解.以下测试环境以手头上有的「 ...
随机推荐
- MVC 授权过滤器 AuthorizeAttribute
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- 简单的oracle sql 语句
创建表空间 create tablespace qnhouse --表空间文件路径 datafile 'E:\qnhost\qnhouse.dbf' --表空间文件大小 size 100M; 创建用户 ...
- python面向对象(上)
创建类 Python 类使用 class 关键字来创建.简单的类的声明可以是关键字后紧跟类名: class ClassName(bases): 'class documentation string' ...
- commands - `ls`
list only directories: ls -d /path/to/*/
- Java Calendar获取年、月、日、时间
Java Calendar获取年.月.日.时间 Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT+08:00" ...
- MYSQL插入处理重复键值的几种方法
当unique列在一个UNIQUE键上插入包含重复值的记录时,默认insert的时候会报1062错误,MYSQL有三种不同的处理方法,下面我们分别介绍. 先建立2个测试表,在id列上创建unique约 ...
- Exception和IOException之间的使用区别
Exception和IOException之间的使用区别 先看一段代码.这段代码来自<深入剖析tomcat> public void await() { // 创建ServerSock ...
- 烧饼(nyoj779)
描述烧饼有两面,要做好一个兰州烧饼,要两面都弄热.当然,一次只能弄一个的话,效率就太低了.有这么一个大平底锅,一次可以同时放入k个兰州烧饼,一分钟能做好一面.而现在有n个兰州烧饼,至少需要多少分钟才能 ...
- MVC4商城项目二:用户身份验证的实现
用户身份验证,依赖于 forms 身份验证类:FormsAuthentication,它是一串加密的cookie 来实现对控制器访问限制和登陆页面的访问控制.它在浏览器端是这样子的: 需求:我们要实现 ...
- MYSQL select ....outfile.....from.....
select .... outfile 'file_path' fields terminate by '\t' lines terminate by '\r\n' from table_name; ...