android以编程方式将键盘视图(布局)从符号更改为qwerty文本

时间:2014-11-25 09:33:00

标签: android android-softkeyboard android-keypad

如何在Android键盘中以编程方式在符号(" Sym")和qwerty(" ABC")之间切换?方案是当我键入特定符号时,说'#',键盘布局应自动更改为' qwerty'。

1 个答案:

答案 0 :(得分:0)

你必须实现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());

    }
});