In my activity there is three editText view it will randomly gets hide at some time 
After entering a single text in the editText the soft-keyboard will disappears automatically
Now I want to show the soft keyboard When editText get focused 
How to do this?
Thanks in advance
            Asked
            
        
        
            Active
            
        
            Viewed 234 times
        
    4
            
            
         
    
    
        user3251646
        
- 278
- 4
- 15
2 Answers
2
            
            
        Through InputMethodManager you can show and hide the soft keyboard. Use toggleSoftInput() method to show soft keyboard when EditText get focus and use hideSoftInputFromWindow() to hide the keyboard when EditText lost focus as below...
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
    @Override
    public void onFocusChange(View v, boolean isFocused) {
        if (isFocused) {
            imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
        } else {
            imm.hideSoftInputFromWindow(getWindow().getCurrentFocus().getWindowToken(), 0); 
        }
    }
});
 
    
    
        Hamid Shatu
        
- 9,664
- 4
- 30
- 41
1
            
            
        Try with these code..
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null) {
    inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
 
    
    
        Nagendra Badiganti
        
- 2,099
- 2
- 22
- 30