简体   繁体   English

没有EditText的Android键盘InputType

[英]Android keyboard InputType without EditText

For an android app with a custom design, I open the keyboard manually as it have no input on which to focus. 对于具有自定义设计的Android应用程序,我手动打开键盘,因为它没有要关注的输入。

I open it using : 我打开它使用:

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
imm.toggleSoftInput (InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);

I would like to set the keyboard as InputType.TYPE_CLASS_NUMBER but can't found any documentation on how to do this. 我想将键盘设置为InputType.TYPE_CLASS_NUMBER,但无法找到有关如何执行此操作的任何文档。

Thanks in advance ! 提前致谢 !

The solution to this problem is to set all the edittext in in a LinearLayout and to set visibility to "Gone" on that LinearLayout and not on the EditText(s). 此问题的解决方案是将所有edittext设置在LinearLayout中,并将该可见性设置为该LinearLayout上的“Gone”而不是EditText。

This way you can still focus on the EditText programmatically by doing a click on any other element. 这样,您仍然可以通过单击任何其他元素以编程方式关注EditText。

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

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