0
Hello! I am new in programming and Android and I came across a question.
What I see in most tutorials is like this.
- A button is created.
- Declares this button as class attribute.
- Retrieves his reference via id inside onCreate.
- Apply a Listener to this button and make the implementation.
Only the other day I saw something different.
- A button is created.
- A public method is created by receiving a View object as a parameter.
- In the onClick attribute of xml this button points to this method and implements it.
The fact that I neither declare nor recover the reference can generate me some problem?
thank you
the only problem you could have would be the fact that you need the same button at another point on the screen, but triggering another event.
– Armando Marques Sobrinho
Related: https://stackoverflow.com/questions/21319996/android-onclick-in-xml-vs-onclicklistener
– Bruno Silva
thank you all, I will read the link
– ito