我可以从android上的代码控制键盘,特别是大写锁定

时间:2011-10-12 20:16:34

标签: android keyboard

是否可以从Android上的代码弹出键盘并设置大写锁定?

2 个答案:

答案 0 :(得分:4)

尝试将add android:capitalize =“characters”添加到EditText属性。这应该在CAPS中显示键盘。

另外,仅供参考,这是您通过代码显示键盘的方式:

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);

答案 1 :(得分:3)

您可以使用capitalize属性将键盘默认设置为所有大写字母:

 <EditText 
        android:layout_height="wrap_content" 
        android:layout_width="match_parent"
        android:capitalize="characters" />

请记住,用户只需关闭“大写锁定”即可。您可以在从EditText检索的String上调用.toUpperCase()

相关问题