我正在制作一个 Android 应用程序,我需要用户填写表格。在此表单中有一个字段,用户必须在其中输入她/他的 ID(例如护照),我想知道是否可以同时显示带有数字和文本的键盘。
提前致谢。
最佳答案
如果你想在运行时设置键盘的类型,使用这个例子:
EditText editText = (EditText) findViewById(R.id.its_your_EditText);
editText.setInputType(EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); //TYPE_CLASS_TEXT is the default
如果您想立即显示键盘,请使用此示例:
if (editText.requestFocus()) {
InputMethodManager imm = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
}
关于android - 在 edittext 中为用户 ID 显示带有文本和数字的键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45708307/