简体   繁体   中英

android - show soft keyboard on demand

Hi I wrapped edittext control onto a control that is being displayed on the screen at users request. It overlays the whole screen until user presses 'done' button on the keyboard.

I am not able to explicitly show the control on the screen. only when user taps into control only then its shown. Am I missing something?

I even try this and it does not brin it up when I launch the overlay that Edit Text exists on:

customCOntrol.showKeyboard();

public void showKeyboard()
    {
        InputMethodManager imm = (InputMethodManager)_context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(this._textView.getWindowToken(), InputMethodManager.SHOW_IMPLICIT);
    }

here is the settig I have on the screen itself in the config file android:windowSoftInputMode="stateHidden|adjustPan"

Thank you in advance

In your showKeyboard function you are calling:

 imm.hideSoftInputFromWindow(this._textView.getWindowToken(), InputMethodManager.SHOW_IMPLICIT);

This will hide the softInput keyboard from the window! Do you want to show the keyboard? If yes then would you use:

 imm.showSoftInput(view, flags, resultReceiver);

EDIT: I think you can also toggle the keyboard from the InputMethodManager, try:

 imm.toggleSoftInput(0, 0);

@dropsOfJupiter

You can do: editText.requestFocus() as you launch the Activity or Fragment containing your EditText reference. This will give the focus to the EditText and will bring uo the SoftKeyboard.

I hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM