void
void

Reputation: 207

Android softkeyboard not triggerring

I have multiple EditText on my screen and one of them is focussed. The softkeyboard does not trigger as soon as the screen pops up. I want the soft keyboard to trigger as soon as the screen pops up. It works well if I don't implement the onFocusChangeListener(). However I need the onFocusChangeListener() to detect which editText is focused. I have tried setting setFocusable(true) and setFocusableInTouchMode(true). Also i don't want to modify the android:windowSoftInputMode property in AndroidMenifest.xml. I have the following criteria :

  1. onFocusChangeListener implemented (to detect which edittext is focused)
  2. No modifications in AndroidMenifest.xml

Here is my code snippet

final InputMethodManager inputMethodManager =  (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

    mInput.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean hasFocus) {
            mIsFocused = hasFocus;
            if(hasFocus)
                inputMethodManager.showSoftInput(mInput, InputMethodManager.SHOW_IMPLICIT);

        }
    });

Any suggestions ?

Upvotes: 0

Views: 40

Answers (2)

Squirrelkiller
Squirrelkiller

Reputation: 2804

You can try using inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0).

Source: Stackoverflow post

Upvotes: 1

Mauricio Collazos
Mauricio Collazos

Reputation: 316

You can open softkeyboard programmatically

getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);

Upvotes: 1

Related Questions