[英]android - show soft keyboard on demand
Hi I wrapped edittext control onto a control that is being displayed on the screen at users request. 嗨,我将edittext控件包装到了根据用户要求显示在屏幕上的控件上。 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" 这是配置文件android:windowSoftInputMode =“ stateHidden | adjustPan”在屏幕上显示的settig
Thank you in advance 先感谢您
In your showKeyboard function you are calling: 在showKeyboard函数中,您正在调用:
imm.hideSoftInputFromWindow(this._textView.getWindowToken(), InputMethodManager.SHOW_IMPLICIT);
This will hide the softInput keyboard from the window! 这将从窗口中隐藏softInput键盘! 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: 编辑:我认为您也可以从InputMethodManager切换键盘,请尝试:
imm.toggleSoftInput(0, 0);
@dropsOfJupiter @dropsOfJupiter
You can do: editText.requestFocus() as you launch the Activity or Fragment containing your EditText reference. 您可以执行以下操作:启动包含EditText引用的Activity或Fragment时,editText.requestFocus()。 This will give the focus to the EditText and will bring uo the SoftKeyboard.
这将把重点放在EditText上,并将带入SoftKeyboard。
I hope this helps. 我希望这有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.