Search code examples
androidsettexttextwatcher

SetText in TextWatcher


I have problem a problem with setText() method. When I type numbers in numeric keyboard after setText numeric keyboard changes automaticaly to characters keyboard. How can I dissmis this action?

textWatcher = new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {}

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

            @Override
            public void afterTextChanged(Editable s) {
                editText.removeTextChangedListener(textWatcher);

                String group = s.toString().toUpperCase();

                editText.setText(group);    
                editText.setSelection(editText.getText().length());
                editText.addTextChangedListener(textWatcher);
            }
        };

Solution

  • I have the same problem. U deen to use RelativeLayout and TextView with your EditText

    And in afterTextChanged use setText to a textView. Here is more detail.