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

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. Android通过PHP连接MySQL(用到Json)

    1下载phpnow 如果已经有mysql 则需要换一个端口 在服务器机器上的phpnow安装目录E:\PHPnow-1.5.5\htdocs下新建一个test.php文件: 其中我用的数据库是test ...

  2. 线程间通信的三种方式(NSThread,GCD,NSOperation)

    一.NSThread线程间通信 #import "ViewController.h" @interface ViewController ()<UIScrollViewDel ...

  3. (zz)Lambda 表达式(C# 编程指南)

    https://msdn.microsoft.com/zh-cn/library/bb397687.aspx Lambda 表达式是一种可用于创建委托或表达式目录树类型的匿名函数.通过使用 lambd ...

  4. java二维码之利用谷歌的zxing生成二维码,解析二维码

    生成二维码 @RequestMapping("/123") public void test(HttpServletRequest request,HttpServletRespo ...

  5. Android 轮询之 Service + AlarmManager+Thread (转)

    android中涉及到将服务器中数据变化信息通知用户一般有两种办法,推送和轮询. 消息推送是服务端主动发消息给客户端,因为第一时间知道数据发生变化的是服务器自己,所以推送的优势是实时性高.但服务器主动 ...

  6. Libreoffice汉化

    汉化过程:在终端下输入即可 sudo apt-get install libreoffice-l10n-zh-cn 注意啦:在汉化libreffice之前,一定要先给ubuntu装上中文字体,否则汉化 ...

  7. ubuntu安装体验

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

  8. 在Struts2中使用poi进行excel操作下载的时候报getOutputStream() has already been called for this response 错误 [转]

    在项目中用到了poi这个开源的操作excel文件的jar. 项目中用到struts2容器管理servlet.不是单纯的直接用servlet.         workbook.write(os);   ...

  9. Python之路第九天,高级(1)-网络编程

    SOCKET编程 socket通常也称作"套接字",用于描述IP地址和端口,是一个通信链的句柄,应用程序通常通过"套接字"向网络发出请求或者应答网络请求. so ...

  10. (八)boost库之异常处理

    (八)boost库之异常处理 当你面对上千万行的项目时,当看到系统输出了异常信息时,你是否想过,如果它能将文件名.行号等信息输出,该多好啊,曾经为此绞尽脑汁. 今天使用boost库,将轻松的解决这个问 ...