【问题标题】:Can i control the keyboard from code on android in particular the caps lock我可以通过android上的代码控制键盘,尤其是大写锁定吗
【发布时间】:2011-10-13 04:26:59
【问题描述】:

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

【问题讨论】:

    标签: android keyboard


    【解决方案1】:

    尝试将 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);
    

    【讨论】:

      【解决方案2】:

      您可以使用capitalize 属性使键盘默认全部为大写字母:

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

      请记住,用户可以简单地关闭“大写锁定”。您可以在从 EditText 检索到的字符串上调用 .toUpperCase()

      【讨论】:

        猜你喜欢
        • 2012-08-10
        • 2011-02-20
        • 1970-01-01
        • 2019-03-25
        • 1970-01-01
        • 2011-08-31
        • 2018-06-08
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多