Android App监听软键盘按键的三种方式与改变软键盘右下角确定键样式
actionNone : 回车键,按下后光标到下一行
actionGo : Go,
actionSearch : 放大镜
actionSend : Send
actionNext : Next
actionDone : Done,确定/完成,隐藏软键盘,即使不是最后一个文本输入框
android:singleline="true"
android:imeoptions="actionSearch"
EditText.setOnEditorActionListener设置监听
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
boolean isOK = true;
switch (actionId) {
case EditorInfo.IME_ACTION_NONE:
Toast.makeText(mContext, "点击-->NONE", Toast.LENGTH_SHORT).show();
break;
case EditorInfo.IME_ACTION_GO:
Toast.makeText(mContext, "点击-->GO", Toast.LENGTH_SHORT).show();
break;
case EditorInfo.IME_ACTION_SEARCH:
Toast.makeText(mContext, "点击-->SEARCH", Toast.LENGTH_SHORT).show();
break;
case EditorInfo.IME_ACTION_SEND:
Toast.makeText(mContext, "点击-->SEND", Toast.LENGTH_SHORT).show();
break;
case EditorInfo.IME_ACTION_NEXT:
Toast.makeText(mContext, "点击-->NEXT", Toast.LENGTH_SHORT).show();
break;
default:
isOK = false;
break;
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.edwin.demokeyboard.MainActivity"> <TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center"
android:text="改变软键盘右下角确定键样式"
android:textSize="20sp" /> <EditText
android:id="@+id/et_main_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="actionGo"
android:imeOptions="actionGo"
android:singleLine="true" /> <EditText
android:id="@+id/et_main_two"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="actionSearch"
android:imeOptions="actionSearch"
android:singleLine="true" /> <EditText
android:id="@+id/et_main_three"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="actionSend"
android:imeOptions="actionSend"
android:singleLine="true" /> <EditText
android:id="@+id/et_main_four"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="actionNext"
android:imeOptions="actionNext"
android:singleLine="true" /> </LinearLayout>

源码地址:
Android App监听软键盘按键的三种方式与改变软键盘右下角确定键样式的更多相关文章
- Android App监听软键盘按键的三种方式
前言: 我们在android手机上面有时候会遇到监听手机软键盘按键的时候,例如:我们在浏览器输入url完毕后可以点击软键盘右下角的“GO”按键加载url页面:在点击搜索框的时候,点击右下角的sea ...
- Android App监听软键盘按键的三种方式(转)
最近有类似需求,在csdn上刚好发现,粘贴过来,以防止忘记喽 前言: 我们在android手机上面有时候会遇到监听手机软键盘按键的时候,例如:我们在浏览器输入url完毕后可以点击软键盘右下角的“G ...
- 键盘-App监听软键盘按键的三种方式
前言: 我们在android手机上面有时候会遇到监听手机软键盘按键的时候,例如:我们在浏览器输入url完毕后可以点击软键盘右下角的“GO”按键加载url页面:在点击搜索框的时候,点击右下角的sea ...
- Android 监听软键盘按键的三种方式
前言: 我们在Android手机上面有时候会遇到监听手机软键盘按键的时候,例如:我们在浏览器输入url完毕后可以点击软键盘右下角的“Go”按键加载url页面:在点击搜索框的时候,点击右下角的searc ...
- C#模拟键盘按键的三种方式实现
1.System.Windows.Forms.SendKeys 组合键:Ctrl = ^ .Shift = + .Alt = % 模拟按键:A private void button1_Click(o ...
- Android如何监听蓝牙耳机的按键事件(转)
源: Android如何监听蓝牙耳机的按键事件 写在前面: 直接想要代码很简单,你直接把滚动条拉到最底端就可以看到.如果想要十分地了解为什么,那就按照我规划的一步一步来理解.以下测试环境以手头上有的「 ...
- Android怎样监听蓝牙耳机的按键事件
Android怎样监听蓝牙耳机的按键事件 写在前面: 直接想要代码非常easy,你直接把滚动栏拉到最底端就能够看到.假设想要十分地了解为什么,那就依照我规划的一步一步来理解.下面測试环境以手头上有的「 ...
- Android如何监听蓝牙耳机的按键事件
写在前面: 直接想要代码很简单,你直接把滚动条拉到最底端就可以看到.如果想要十分地了解为什么,那就按照我规划的一步一步来理解.以下测试环境以手头上有的「Bluedio + 红米手机」. 1.蓝牙耳机的 ...
- android activity中监听View测量完成的4种方式
在开发中经常碰到需要在activity初始化完成后获得控件大小的情况. 但是这个操作我们不能在oncreate.onresume等生命周期方法中调用,因为我们不知道何时view才能初始化完成 为此,特 ...
随机推荐
- Javascript动画效果(二)
Javascript动画效果(二) 在前面的博客中讲了简单的Javascript动画效果,这篇文章主要介绍我在改变之前代码时发现的一些问题及解决方法. 在前面的多物体宽度变化的例子中,我们给其增加代码 ...
- TFS 2012 在IE11和Chrome (Windows 8.1) 显示英文的解决方案
1.如果使用IE11浏览TFS Web显示英文,请执行以下操作: 控制面板——>语言——>高级设置 将“替代Windows显示语言”改为“中文(中华人民共和国)”,同时勾选“Web语言”下 ...
- TreeView 自定义显示checkbox
本项目需要对TreeView进行定制,要求比较简单,主要要求如下: Winform中TreeView控件默认只支持所有级别的CheckBox显示或者不显示,不能控制制定Level的树节点显示 效果如下 ...
- C#读取Appconfig中自定义的节点
今天在使用Nlog的时候,发现了一个之前没注意的问题. 以前,我的app配置文件都是这么写的,当然配置比较多的时候会改用xml. 如果<appSettings>节点中的内容很多的话,我自己 ...
- iOS 学习笔记二【cocopods安装使用和安装过程中遇到的问题及解决办法】【20160725更新】
在osx 10.11之前cocopods问题不多,但是升级到11之后的版本,之前的cocopods大多用不了,需要重新安装,对于我这种使用测试版系统的技术狂来说,每次都需要重新安装很多东西, 当然,c ...
- 【从API学英语】-DriverManager
原文: The basic service for managing a set of JDBC drivers. NOTE: The DataSource interface, new in the ...
- input框中的size和maxlength的区别
- 修正 XE5 Android 键盘三个问题
说明:XE5 在 Android 平台上存在这一些键盘操作的问题,目前发现有下列几种: 按键盘上的隐藏键后,无法按上一页(需要修改 XE5 源码「FMX.VirtualKeyboard.Android ...
- Gym 101102C---Bored Judge(区间最大值)
题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...
- 比特币Bitcoin源代码安装编译
body{ font: 16px/1.5em 微软雅黑,arial,verdana,helvetica,sans-serif; } 比特币 (货币符号: ฿;英文名:Bitcoin;英文 ...