zoukankan      html  css  js  c++  java
  • Android自定义搜索框

    搜索框里的虚拟键盘

    xml如下

    <EditText android:id="@+id/et_shopshow_search"
                android:layout_width="144dp"
                android:layout_height="40dp"
                android:singleLine="true"
                android:paddingLeft="8dp"
                android:paddingRight="8dp"
                android:drawablePadding="8dp"
                android:hint="@string/kuanhao"
                android:background="@color/white"
                android:drawableLeft="@drawable/searchcommon_icon"
                android:focusableInTouchMode="true"
                android:textSize="16sp"
                android:layout_marginLeft="8dp"
                android:layout_marginRight="8dp"
                android:layout_weight="1"
                android:imeOptions="actionSearch" />

    在代码里加入keydown时间的重写

    final EditText et_search=(EditText)findViewById(R.id.et_shopshow_search);
            et_search.setOnEditorActionListener(new OnEditorActionListener() {
                @Override
                public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                    if(actionId ==EditorInfo.IME_ACTION_SEARCH){//这是搜索
                        // 先隐藏键盘
                        ((InputMethodManager) et_search.getContext().getSystemService(Context.INPUT_METHOD_SERVICE))
                        .hideSoftInputFromWindow(ShopShowActivity.this.getCurrentFocus().getWindowToken(),InputMethodManager.HIDE_NOT_ALWAYS);
                         
                        //根据搜索框内容进行查询 
                        _styleCode=v.getText().toString().trim();
                        InitPageTask task = new InitPageTask(ShopShowActivity.this);
                        task.execute("");
                        return true;
                    }
                    return false;
                }
            });

     

  • 相关阅读:
    chrome浏览器下载地址
    RFC1925 The Twelve Networking Truths
    The Design Philosophy of the DARPA Internet Protocols
    Internet only just works
    Windows Xp下浏览器支持现状
    一些在线翻译网站
    近期随想20210123
    写可测试的代码,重视工程质量
    composer 相关
    MySQL 主从延迟导致业务数据不一致
  • 原文地址:https://www.cnblogs.com/jxyZ/p/4014935.html
Copyright © 2011-2022 走看看