I have a TextWatcher set up and working (nearly) exactly as I want it. However, I would like this TextWatcher to stop as soon as the user enters a '.'. The only solution I have found so far crashes the app if the user entirely deletes the text. It is also important that the ENTIRE TextWatcher ends at the moment the user enters a '.'.
I have tried placing the TextWatcher within the loop, however it doesn't seem to work.
private TextWatcher userEnterListener = new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
if(after==0) {
shownText = "Please try again";
}
else if(after==1) {
shownText = "A";
}
else if(after==2) {
shownText = "An";
}
else if(after==3) {
shownText = "And";
}
else if(after==4) {
shownText = "Andr";
}
else if(after==5) {
shownText = "Andro";
}
else if(after==6) {
shownText = "Androi";
}
else if(after==7) {
shownText = "Android";
}
else if(after==8) {
shownText = "Android A";
}
else if(after==9) {
shownText = "Android Ap";
}
else if(after==10) {
shownText = "Android App";
}
else {
shownText = "Please try again";
}
}
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
recordedString = (s.toString());
update();
}
};