animation - Android on focus change listener is not working properly -


i working on android app , trying implement feature have found online. tying when user clicks on edit text, example, if user clicks on "username" edit text, setonfocuschangelistener check things , start animation label fadein , fadeout, here codes

usersignuppasswordet.setonfocuschangelistener(new view.onfocuschangelistener() {             @override             public void onfocuschange(view v, boolean hasfocus) {                 if (usersignuppasswordet.hasfocus()) {                     signuppasswdtv.startanimation(fadein);                 } else {                     if (usersignuppasswordet.gettext().tostring().length() == 0) {                         signuppasswdtv.startanimation(fadeout);                     }                 }             }         }); 

the feature trying here, on youtube. problem facing have 3 fields, username, password , email. if click on username working , fadin animation username label works , if not enter fadeout animation works when move other edit text , other edit text's own setonfocuschangelistener works. problem if don't enter in of them keep switching them, keep changing focus, other 2 edit text's setonfocuschangelistener gets triggered , starts fadein animation , fadeout animation. don't know do. suggestion? remember, if don't enter in edit field , keep changing/toggling them, problem getting triggered. if enter in one, changes , label stays visible.

you can add logic on textchangedlistener()

edittext.addtextchangedlistener(new textwatcher() {          @override         public void ontextchanged(charsequence arg0, int arg1, int arg2,                 int arg3) {          }          @override         public void beforetextchanged(charsequence arg0, int arg1,                 int arg2, int arg3) {         }          @override         public void aftertextchanged(editable et) {          }     }); 

so animation called when enter on edittext


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -