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如何监听蓝牙耳机的按键事件 写在前面: 直接想要代码很简单,你直接把滚动条拉到最底端就可以看到.如果想要十分地了解为什么,那就按照我规划的一步一步来理解.以下测试环境以手头上有的「 ...
随机推荐
- 代码初始化 故事板初始化 xib初始化总结
对象的初始化有三种方式 // 代码创建 - (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { ...
- 合理的使用size_t可以提高程序的可移植性和代码的可读性,让你的程序更高效。
最近研读STL源码时,发现里面有很多ptrdiff_t类型的数据,这与size_t的作用类似.以下是一篇关于size_t等平台无关类型的作用,写得很清楚.特将其记录下来. http://blog.cs ...
- 【Lucene4.8教程之二】索引
一.基础内容 0.官方文档说明 (1)org.apache.lucene.index provides two primary classes: IndexWriter, which creates ...
- DOMDocument类文件
http://php.net/manual/en/class.domdocument.php <?php $xml = <<< XML <?xml version=&qu ...
- python基础教程第5章——条件循环和其他语句
1.语句块是在条件为真(条件语句)时执行或者执行多次(循环语句)的一组语句.在代码前放置空格来缩进语句即可穿件语句块.块中的每行都应该缩进同样的量.在Phyton中冒号(:)用来标识语句块的开始,块中 ...
- To and Fro(字符串水题)
To and Fro 点我 Problem Description Mo and Larry have devised a way of encrypting messages. They first ...
- humble number(hd1058)
Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The ...
- 正式学习 react(三)
有了基础的webpack基础,我们要对react的基本语法进行学习. 我这个教程全部用es6 实现.可能会忽略一些最基本的语法讲解,这些你在官网上或者其他别的地方都比我讲的全. 今天我要讲一下reac ...
- 【FSFA 读书笔记】Ch4 Volume Analysis & Cr 5 PC-based Partitions
Volume Analysis 1. “卷”可以理解为从逻辑上对物理存储设备的重新编制,便于操作系统管理. (A volume is a collection of addressable secto ...
- poj2301
Beat the Spread! Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 17794 Accepted: 8484 ...