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