1. 程式人生 > >解決專案中複製網址後,黏貼到搜尋框裡面,系統軟體盤未彈起

解決專案中複製網址後,黏貼到搜尋框裡面,系統軟體盤未彈起

解決這個問題就主要兩句核心的程式碼:

 etSearch.addTextChangedListener(new TextWatcher() {
       public void onTextChanged(CharSequence s, int start, int before, int count) 
       {
                // 黏貼完網址後彈起鍵盤
                InputMethodManager inputManager = (InputMethodManager) etSearch.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                inputManager.showSoftInput(etSearch, 0);

           
        }

 public void beforeTextChanged(CharSequence s, int start, int count, int after) { }

 public void afterTextChanged(Editable s) {}
        });