【问题标题】:android programmatically change keyboard view(layout) from symbol to qwerty textandroid以编程方式将键盘视图(布局)从符号更改为qwerty文本
【发布时间】:2014-11-25 09:33:00
【问题描述】:

如何在 Android 键盘中以编程方式在 symbol("Sym") 和 qwerty("ABC") 之间切换?场景是当我输入一个特定的符号时,比如“#”,键盘布局应该自动更改为“qwerty”。

【问题讨论】:

    标签: android android-softkeyboard android-keypad


    【解决方案1】:

    你必须实现 EditText changeListener

    editText= (EditText)findViewById(R.id.editText);
    
    editText.addTextChangedListener(new TextWatcher()
    {
        public void afterTextChanged(Editable s) 
        {
        }
        public void beforeTextChanged(CharSequence s, int start, int count, int after){}
        public void onTextChanged(CharSequence s, int start, int before, int count)
        {
         ///if it contains # symbol
          //To only allow numbers:
               editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_CLASS_NUMBER);
    
          //To transform (hide) the password:
    
               editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
    
        }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-07-14
      • 1970-01-01
      • 2012-06-27
      • 1970-01-01
      • 2015-07-17
      • 2012-07-08
      • 1970-01-01
      相关资源
      最近更新 更多