【发布时间】:2011-10-13 04:26:59
【问题描述】:
是否可以通过android上的代码弹出键盘并设置大写锁定?
【问题讨论】:
是否可以通过android上的代码弹出键盘并设置大写锁定?
【问题讨论】:
尝试将 add android:capitalize="characters" 添加到 EditText 属性。这应该以大写字母显示键盘。
另外仅供参考,这是您通过代码显示键盘的方式:
EditText editText = (EditText) findViewById(R.id.myEdit);
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
// only will trigger it if no physical keyboard is open
mgr.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
【讨论】:
您可以使用capitalize 属性使键盘默认全部为大写字母:
<EditText
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:capitalize="characters" />
请记住,用户可以简单地关闭“大写锁定”。您可以在从 EditText 检索到的字符串上调用 .toUpperCase()。
【讨论】: