So, I want user to write two numbers divided by this symbol ":" in EditText. I've added TextWatcher to this EditText, so I can see what user is typing.
Thus, that's what I have in my Watcher in afterTextChanged.
@Override
public void afterTextChanged(Editable s)
{
String textToEdit = s.toString();
if (s.length()==2)
{
String h = s.toString();
h = h+":";
edit.setText(h);
edit.setSelection(edit.getText().length());
}
}
When user type more than 2 digits, I'm adding ":" to EditText.
And here I have problem. Input type of this EditText is "number", so, only numbers can be there and ":" is not a number.
Little example: User typed 24. afterTextChanged get it and add set "24:". 24 was a number , "24:" is a string.
So, now I have "24:" and when I try to delete something from EditText I get fatal error.
Is there any other way to show ":" in my EditText? Or what I'm doing wrong?