我正在创建一个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);
}