简体   繁体   English

以编程方式打开Android数字键盘

[英]Open Android numeric keyboard programmatically

How can I open Android's numeric keyboard programmatically? 如何以编程方式打开Android的数字键盘?

I know how to set the EditText to numeric and initiate numeric keyboard but I want a solution without EditText or Layout because I am trying to open the keyboard for Webview. 我知道如何将EditText设置为数字并启动数字键盘,但是我想要一个没有EditText或Layout的解决方案,因为我正试图为Webview打开键盘。

Have u tried this. 你尝试过这个吗?

  InputMethodManager inputMethodManager =
  (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInputFromWindow(linearLayout.getApplicationWindowToken(),
    InputMethodManager.SHOW_FORCED, 0);

and this to your oncreate() 这到你的oncreate()

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);

Try this 尝试这个

EditText etxt = new EditText(this);

etxt.setInputType(InputType.TYPE_CLASS_NUMBER);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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