What are the two ways to add Event Listeners to buttons in Android?
I have seen that you can specify the listener within the XML. I personally prefer this way as it usually involves less code. I know some people like to create an anonymous inner class...
I'm relatively new to programming in Android, so this question is purely to expand my knowledge. Be interested to hear what the community has to say on this!
Jack
It depends on your tasks. In one case specify listeners in XML is enough. In other case, for example, when you create buttons dynamically in code, you will need to have defined listener in code or create anonymous inners. Another situation when the listener is used as parameter of method and you won't be able to specify it in XML.