Search code examples
androidandroid-viewandroid-custom-view

How to know which view can implement what listener


I would like to know, from where we can know about what listener a View can implement. For Ex. there is no meaning in implementing onItemSelectedListener in custom Edit Text view class.


Solution

  • You should refer to the documentation (View, for example), there's a Nested Classes section that describes a list of interfaces that every View provides. For example, View class the OnClickListener interface, means every subclass of View would also provide it. And AdapterView (which is a parent of a ListView) provides the OnItemSelectedListener, means ListView will provide both OnClickListener and OnItemSelectedListener. Hope this helps.