zoukankan      html  css  js  c++  java
  • 查找后去掉EditTextView的焦点

    //在按钮点击事件里处理

    bt_search.setOnClickListener(new OnClickListener() {


                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    String strSearch = ed_input.getText().toString();
                     SQLiteDatabase db = VSmsDBUtil.createOrOpenDatabase();
                     LogWrapper.i("search", "db = "+db);
                     Cursor cursor =
                     db.rawQuery("SELECT sTitle, sContent, sTime, sImage FROM msgtab where ( findItem like ?)",
                     new String[]{"%"+strSearch+"%"});
                    tempListSms = new ArrayList<TestSmsBean>();
                     if( cursor != null ){
                           if( cursor.moveToFirst() ){
                               do{
                                       TestSmsBean tsb = new TestSmsBean(
                                               cursor.getString(0),
                                               cursor.getString(1),
                                               cursor.getString(2),
                                               cursor.getString(3));
                                     tempListSms.add(tsb);
                                    }while( cursor.moveToNext());
                              }
                           adapter.assignment(tempListSms);

                            listView.setAdapter(adapter);
                            adapter.notifyDataSetChanged();
                         }else{
                             Toast.makeText(getApplicationContext(), "对不起,没找到匹配的结果", Toast.LENGTH_LONG).show();

                            
                         }
                        cursor.close();
                        db.close();
                        
                        //ed_input是EditTextView
                        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                        if (!ed_input.isFocusable()) {
                            // searchauto.setInputType(InputType.TYPE_NULL);
                            // imm.showSoftInputFromInputMethod(AutoCompleteTextView_testActivity.this.getCurrentFocus()
                            // .getWindowToken(), 0);
                            imm.showSoftInputFromInputMethod(ed_input.getWindowToken(),
                                    0);
                            LogWrapper.i("vvvv","ed_input,hasFocus true");
                            isFresh = false;
                        } else {
                            try {
                                // imm.hideSoftInputFromWindow(AutoCompleteTextView_testActivity.this.getCurrentFocus().getWindowToken()
                                // , 0);
                                imm.hideSoftInputFromWindow(ed_input.getWindowToken(),
                                        InputMethodManager.HIDE_NOT_ALWAYS);
                                LogWrapper.i("vvvv","ed_input,hasFocus false");
                                isFresh = true;
                            } catch (Exception e) {
                                
                                
                            }
                        }
                        
                }
            });

        }

  • 相关阅读:
    ES基础(十三)Dynamic Template和Index Template
    ES基础(十一)显式Mapping设置与常见参数介绍
    ES基础(十)Dynamic Mapping 和常见字段类型
    ES基础(九)Query & Simple Query String Query
    ES基础(八)Request Body 与 Query DSL
    Docker 核心技术与实现原理
    error gathering device information while adding custom device
    Linux下使用内核源码单独编译某一模块
    kata container endpoint
    Virtio_user for Container Networking
  • 原文地址:https://www.cnblogs.com/dyllove98/p/3194243.html
Copyright © 2011-2022 走看看