OrMoush
OrMoush

Reputation: 205

android Try to open keyboard after click on editText

I'm trying to open keyboard and i get in the logcat

682-682/com.android.inputmethod.latin V/InputMethodService﹕ onEvaluateInputViewShown: config.hardKeyboardHidden = 1

my code:

   InputMethodManager imm = (InputMethodManager) this.getSystemService(Service.INPUT_METHOD_SERVICE);

    editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
            } else {

            }
        }
    });

Thank you !

Upvotes: 1

Views: 473

Answers (2)

InnocentKiller
InnocentKiller

Reputation: 5234

Try this,

Declare this at top of your activity

InputMethodManager imm = (InputMethodManager)this.getSystemService(Service.INPUT_METHOD_SERVICE);

and inside edittext just use this,

imm.showSoftInput(editText, 0);

or else you can try this too,

InputMethodManager m = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
  if(m != null){
      m.toggleSoftInput(0, InputMethodManager.SHOW_IMPLICIT);
   } 

Upvotes: 1

Vamshi
Vamshi

Reputation: 1495

Try this:

editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if (actionId == EditorInfo.IME_ACTION_SEARCH) {

            return true;
        }
        return false;
    }

});

Upvotes: 1

Related Questions