android programmatically change keyboard view(layout) from symbol to qwerty text

2k Views Asked by At

How to programmatically toggle between symbol("Sym") and qwerty("ABC") in Android keyboard? The Scenario is when I type a particular symbol, say '#', the keyboard layout should automatically change to 'qwerty'.

1

There are 1 best solutions below

0
On

you have to implement 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());

    }
});