登录界面有一个输入用户名和密码的编辑框:

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输入法 监听事件的更多相关文章

  1. android editText 监听事件

    在软键盘中注意 在监听的 edittext中 使用android:imeOptions属性的时候,一定要对EditText设置 android:inputType 或者 设置 android:sing ...

  2. Android onclick监听事件打开新界面

    一.新建工程 二.新建XML代码 新建一个Button <Button android:layout_width="wrap_content" android:layout_ ...

  3. android EditText监听事件及参数详解

    editText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence ...

  4. android典型监听事件实

    public class MainActivity extends Activity { int counter; Button add, sub; TextView display; @Overri ...

  5. xamarin android如何监听单击事件

    在xamarin android单击事件是最基础的事情,看过菜鸟上的android教程时,java写的都是监听事件,为一个按钮,单选按钮.多选按钮的单击事件有三种,前面两种用的非常普遍,也很简易,我这 ...

  6. Android中Button的五种监听事件

    简单聊一下Android中Button的五种监听事件: 1.在布局文件中为button添加onClick属性,Activity实现其方法2.匿名内部类作为事件监听器类3.内部类作为监听器4.Activ ...

  7. Android如何监听蓝牙耳机的按键事件

    写在前面: 直接想要代码很简单,你直接把滚动条拉到最底端就可以看到.如果想要十分地了解为什么,那就按照我规划的一步一步来理解.以下测试环境以手头上有的「Bluedio + 红米手机」. 1.蓝牙耳机的 ...

  8. 一步一步学android之事件篇——单选按钮监听事件

    在平常使用软件的时候,我们经常会碰见一些选择题,例如选择性别的时候,在男和女之间选,前面说过这个情况要用RadioGroup组件,那么点击了之后我们该怎么获取到选择的那个值呢,这就是今天要说的OnCh ...

  9. Android如何监听蓝牙耳机的按键事件(转)

    源: Android如何监听蓝牙耳机的按键事件 写在前面: 直接想要代码很简单,你直接把滚动条拉到最底端就可以看到.如果想要十分地了解为什么,那就按照我规划的一步一步来理解.以下测试环境以手头上有的「 ...

随机推荐

  1. ubuntu安装体验

    本文记录一下昨晚及今天安装ubuntu系统的过程及体验 2016年6月13日09:36:11 更新 今天才有发现原来自己有个没填的坑 = = 那次安乌班图后第一感觉是很好用,新鲜了好几天,但是很快,新 ...

  2. C# 添加服务引用。

    1,服务引用给的实例(需要一个网址连接) http://192.168.17.131:12170/amtiot.gis.WCF/SpatialAnalysis.svc  (类似于这样的一个网址) 在网 ...

  3. SSM三大框架整合详细教程

    使用SSM(Spring.SpringMVC和Mybatis)已经有三个多月了,项目在技术上已经没有什么难点了,基于现有的技术就可以实现想要的功能,当然肯定有很多可以改进的地方.之前没有记录SSM整合 ...

  4. SimpleDateFormat的使用

    SimpleDateFormat 是一个以国别敏感的方式格式化和分析数据的具体类. 它允许格式化 (date -> text).语法分析 (text -> date)和标准化. 下面是个小 ...

  5. 优酷播放器demo

    <!DOCTYPE html> <html lang="en-US"> <head> <meta http-equiv="Con ...

  6. paul的cnblog,欢迎大家的光临

    我会在blog里面分享各种资源,技术文章,大家多多交流,欢迎拍砖.

  7. PHP记录点击数方法

    1.第一种方法: $id = $_GET['id']; //获取文章ID $sql = "UPDATE base SET hits = hits+1 WHERE id = '$id'&quo ...

  8. 理解Window和WindowManger

    一.Window简介 作用:桌面上显示一个类似悬浮的东西. 介绍:Window是一个抽象类,实现是由PhoneWindow.WindowManager是外界访问Window的入口.但是最终实现是在Wi ...

  9. Red and Black(水)

    Red and Black Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  10. 当 IDENTITY_INSERT 设置为 OFF 时,不能为表 'tb_MyInvoices' 中的标识列插入显式值

    默认情况下,IDENTITY_INSER就是off 这种情况下,你写insert 语句时,identity栏位,不要写值,系统会自动帮你写入. 举例说明: ,),dt datetime,pay int ...