EditText password = findViewById(R.id.passwordEditText); password.setTransformationMethod(new PasswordTransformationMethod());
EditText text = findViewById(R.id.uppercaseEditText); text.addTextChangedListener(new TextWatcher() { public void beforeTextChanged(CharSequence s, int start, int count, int after) {} public void onTextChanged(CharSequence s, int start, int before, int count) {} public void afterTextChanged(Editable s) { String text = s.toString().toUpperCase(); if (!text.equals(s.toString())) { s.replace(0, s.length(), text); } } });This code creates an instance of the TextWatcher interface and attaches it to the EditText widget. The afterTextChanged() method is called every time the text in the widget changes. It converts the entered text to uppercase and replaces the widget's contents with the modified text. The android.widget.EditText class and its setTransformationMethod() method are part of the Android API's core package library (android.widget).