Search code examples
androidkeyboard

To Hide Keyword after input on EditText


I typed phone number into edittext. then i want to go next view, because of the next view hide by keyword, so how can i hide this, during this situation, how can i handle this?

enter image description here


Solution

  • To hide the soft keyboard after you have finished typing and clicked on enter button.

    Textview.setOnEditorActionListener(new TextView.OnEditorActionListener()
        {
    
            @Override
    
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    
                if (actionId == EditorInfo.IME_ACTION_DONE) {
    
                  //your content
    
                   }
    
                 /*This code will basically hide the keyboard*/
    
                InputMethodManager imm = 
                (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
                 imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); 
    
    
                return false;
            }
        });
    

    In this code after you have finished typing user will hit enter key and keyboard will hide the soft keyboard.