用过就忘,软键盘搜索按钮

AutoCompleteTextView设置键盘搜索按钮

<AutoCompleteTextView

   android:id="@+id/harSearch"    android:layout_width="0dp"    android:singleLine="true"    android:drawableLeft="@drawable/sousuo"    android:hint="搜索"    android:imeOptions="actionSearch"    android:layout_weight="10"    android:layout_height="wrap_content"    android:completionThreshold="1"

   />
android:imeOptions="actionSearch" //设置键盘搜索按钮
android:singleLine="true" //设置单行,不设置则显示回行按钮。找不到搜索按钮= =

后台处理

.setOnEditorActionListener(TextView.OnEditorActionListener() {
    onEditorAction(TextView v, actionId, KeyEvent event) {
        (actionId == EditorInfo.) {

            .clearFocus();
            searchListView();
            ;
        }
        ;
    }
时间: 2024-07-30 13:53:16

用过就忘,软键盘搜索按钮的相关文章

android设置软键盘搜索键以及监听搜索键点击时发生两次事件的问题解决

如图所示,有时候为了布局美观,在搜索时没有搜索按钮,而是调用软件盘上的按钮.调用的实现只需要在XML在输入框中加入android:imeOptions="actionSearch",调用软键盘时,回车键就会显示搜索二字. 然后调用 OnEditorActionListener,不是OnKeyListener searchText.setOnEditorActionListener(new OnEditorActionListener() { @Override public boole

&lt;Android&gt;监听软键盘打开收起事件(软键盘自带收起按钮)

最近在公司开发cocos2dx上的android输入框控件,遇到软键盘的事件监听,通常软键盘的收起方式大致3种: 1.点击软键盘右下角的Return按钮(系统收起) 2.输入框焦点时按返回按钮(系统收起) 3.点击软键盘和输入框的外部(自发收起) 4.点击软键盘自带的收起按钮(软键盘收起) 前三种事件可以监听,方式都比较简单 1.点击软键盘右下角的Return按钮 给输入框设置监听 editText.setOnEditorActionListener(new OnEditorActionList

彻底搞定Android开发中软键盘的常见问题

软键盘显示的原理 软件盘的本质是什么?软键盘其实是一个Dialog. InputMethodService为我们的输入法创建了一个Dialog,并且将该Dialog的Window的某些参数(如Gravity)进行了设置,使之能够在底部或者全屏显示.当我们点击输入框时,系统对活动主窗口进行调整,从而为输入法腾出相应的空间,然后将该Dialog显示在底部,或者全屏显示. 软键盘显示的调整 Android定义了一个属性,名字为windowSoftInputMode, 这个属性用于设置Activity主

android 打开软键盘

<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

android 软键盘回车键捕获

EditText editText2 = (EditText)findViewById(R.id.txtTest2); editText2.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) { if (arg1 == EditorInfo.IME_ACTION_UNSPECI

android将软键盘显示为搜索键

方法很简单,首先要在EditText的属性加入 android:imeOptions="actionSearch" ,这个属性的作用是启用软键盘时将回车键设置成搜索键, android:singleLine="true"这个就是为了单行输入的大家都知道. 然后就是监听搜索按钮点击事件了,代码如下: EditText test=(EditText) findViewById(R.id.test); test.setOnEditorActionListener(new

安卓软键盘的搜索

//软键盘的搜索按钮 et_searchinput.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (i == EditorInfo.IME_ACTION_SEARCH || i == EditorInfo.IME_ACTION_UNS

开发移动端web应用, 使用手机自带键盘的搜索按钮

很多时候在移动端的web页面中, 需要使用搜索功能, 然而页面中并没有太多的空间来放置一个像pc端上那样的搜索按钮, 这时候就需要借用手机输入法自带的搜索按钮来实现点击搜索 虽然不是什么大的功能, 但是确实很实用,  实现的效果有一下两点 1. 点击input元素, 弹出的键盘右下角显示为 "搜索" 二字 2. 点击搜索时, 可以出发页面中的js事件 代码如下 1 <!doctype html> 2 <html lang="en"> 3 &l

ios上有时候提交按钮点击两次才可以取消输入框软键盘

ios上有时候提交按钮点击两次才可以取消输入框软键盘,点击第一次软键盘消失,点击第二次输入框页面消失,这样用户体验不好.我的做法是用 touchstart 代替click来处理 反应快,但是有时候会出现 输入框消失后 软键盘又弹出来了,得手动关闭软键盘才可以,这个时候给输入框一个主动取消焦点的事件就可以解决 $("..").blur();