Closed tahirietrit-zz closed 8 years ago
There are a few different ways you can accomplish that. The most direct one would be to add the OnClickListener to the header view on the onBindHeaderViewHolder
method of the adapter. Just create it as an anonymous class and pass in the information you need. This may not always play nice as handling click events on the header should probably have an effect on the rest of the app/UI which will most likely not be accessible from within the adapter.
An (arguably better) approach would be to create your own listener interface, pass it to your adapter then wrap it in an OnClickListener. This way you can have your Activity
or Fragment
implement this interface and handle the click. Whatever implements this interface should have access to the components it needs to properly handle the clicks.
Lastly, the most flexible solution would involve the use of a different mechanism such as a bus (Otto) or reactive extensions (RxJava) to notify the proper component that the header has been clicked.
How can I handle a click event in Header Decor?
Please refer to issue #26 as that has the most up-to-date information on this issue.
Please can any one help me to add click event to the header views?