I am now learning Android and one exercise is requiring me to implement onFocusChangeListener
when a EditText
is touched. However, I was able to find very little information about onFocusChangeListener
. On the Android Development website here there is very very brief information. I have done search but I was only able to find some posts about the specific problems developers have encountered where very few information was given. Can anyone give me an introduction here or any link that talks about that more in detail?
thank you.
As the link you posted says,
and if you read what the
params
meanSo if you set this on a
EditText
, or multipleEditText
s, you can use thev
param to know whichView
s focus has changed. And you can usehasFocus
to determine if it did just gain focus (returns true
) or if it has just lost focus because it was given to someone else (returns false
).So, maybe you want to start some
animation
on aView
when focus is changed on it or anotherView
, you set this listener and when it is invoked you can start theanimation
ifhasFocus
returnstrue
.If you are still confused then please explain what you don't understand about it.
As for the docs not giving much information, they assume that when reading this you have adequate information of what
listeners
and methods do and about how to useparameters
that it takes and returns. The docs also expect a certain knowledge of Java. So for your other question, I know if I don't understand something because I don't think the Android docs have covered it thoroughly, then I would check the Java docs.Java Listeners
Java 6 Docs