1

I have to use stateHidden in Manifest for some reason. But I also need to display keyboard as default for a onCreate(). But whatever I do, the keyboard still not pops-up as default.

I have tried:

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(mText, InputMethodManager.SHOW_IMPLICIT);

And:

InputMethodManager inputManager = (InputMethodManager)mText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);  
         inputManager.showSoftInput(mText, 0);  
Ismael Di Vita
  • 1,806
  • 1
  • 20
  • 35
bianlei
  • 59
  • 1
  • 8

2 Answers2

0

Try set a listener to FocusChanger and force the request focus with the inputMethodCall.

mText.setOnFocusChangeListener(new OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                editText.post(new Runnable() {
                    @Override
                    public void run() {
                        InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
                        imm.showSoftInput(mText, InputMethodManager.SHOW_IMPLICIT);
                    }
                });
            }
        });
mText.requestFocus();

Check if your manifest is stateHidden instead stateAlwaysHidden

Ismael Di Vita
  • 1,806
  • 1
  • 20
  • 35
0

Maybe this post will help you. You need to add android:focusableInTouchMode="false" to the main LinearLayout.

Community
  • 1
  • 1
  • Unfortunately, your one still not work in my case.. I also tried to put it in other layout attributes, still nothing happend. – bianlei Nov 10 '14 at 00:20