I have EditText in myApp with this TextWatcher and numberSigned input type:
TextWatcher() {
@Override
public void afterTextChanged(Editable s)
{
codeinput.removeTextChangedListener(this);
String text = s.toString();
text = text.replaceAll("[^0-9]", "");
if (text.length() > 4)
text = text.substring(0, 4);
String newText = "";
for (char c : text.toCharArray())
newText += c + " ";
text = newText.trim();
String substring = "_ _ _ _".substring(text.length());
text += substring;
int length = text.replaceAll("([ ]?[_])+$", "").length();
codeinput.setText(text);
codeinput.setSelection(length);
codeinput.addTextChangedListener(this);
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) { }
};
When i change input type from numberSigned to numberPassword - all symbols in my EditText is hidden, i want to hide only numbers. How can i do it?
I'm affraid that password type field hides all characters and you can't do anything with that
but consider using setLetterSpacing and don't use spaces (method available since API21)
if you need lower API support and you still want to use
numberPassword
then you have to set up 4EditText
s - useeditText.requestFocus
for jumping to another/nextView
. or you may keep oneEditText
withnumberSigned
, but exchange during text entering all digits to asterisks (keeping digits in some separated value, aseditText.getText
will return you only asterisks)