Other platforms have a facility for specifying prompt text to appear in a text entry box, but I don't see an Android way to do it (though I'm no expert). You could easily fake it, though, by making the background of the EditText transparent and placing a TextView behind it containing the prompt text. Clear the prompt text with the first keystroke in the EditText.
On Oct 13, 4:43 pm, chcat <vlyamt...@gmail.com> wrote: > Hi all, > I am trying to implement simple user input validation in EditText, > something like > > setText("type your password:") > ... > if ( user input != "secretword") > > setText("incorrect, try again: ") > > So i am using "onTextChanged" to validate keyboard input, but how can > i set the text without going to infinite loop? > Thank you, > -V > > EditText tv = new EditText(this); > tv.setText("type password >>"); > tv.addTextChangedListener(new TextWatcher() { > public void afterTextChanged(Editable s) { > //XXX do something > } > public void beforeTextChanged(CharSequence s, int start, int > count, > int after) { > Log.w("before text changed: ", s.toString()); > } > public void onTextChanged(CharSequence s, int start, int > before, int count) { > //validate here and do what? > > } > > }); -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en