ebarrenechea / header-decor

A couple of sticky header decorations for android's recycler view.
Apache License 2.0
878 stars 159 forks source link

On click not working #26

Closed dphart closed 8 years ago

dphart commented 8 years ago

viewHolder.buttonDelete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.v("test", "clicked delete"); } });

isn't working. I'm setting this in the onBindViewHolder(). How do I implement on click?

ebarrenechea commented 8 years ago

@dphart Some other people have complained about the issue as well, as issue #16, for example and I decided to check it out. Indeed this won't work for a very simple reason, the recycler view is the one that handles the drawing and clicking and decorations aren't really part of it's views. For it to work we'll need to handle the clicks through a RecyclerView.OnItemTouchListener.

I've added support for identifying the headers and subheaders that were clicked on the library, but that still requires that the developer implement the not so trivial task of handling motion events. It is sitting in the header_click branch for now. Please have a look at it and let me know if this would help address your issue. Thanks! :)

dphart commented 8 years ago

I was actually referring to the on click on any element in the recyclerview. I'm trying to make it when I click a button on my view, that it will respond. Usually this isn't an issue, but I'm going to assume the header is somehow covering the normal view? I haven't looked too much at your implementation. I'll take a look at the onitemtouch though

ebarrenechea commented 8 years ago

@dphart The header doesn't cover the view and setting and the usual click handling on the adapter should be all you need.

notnotme commented 8 years ago

Hello, I just added the header_click branch in my project's dependencies but even after a clean/rebuild the code of the lib is not updated. This mean that I cannot access StickyHeaderDecoration.findHeaderViewUnder(float x, float y) and I'm unable to handle header click.

Did you know how to fix it ?

The code of the lib did not change whatever version I use,

ca.barrenechea.header-decor:header-decor:0.2.5

or

ca.barrenechea.header-decor:header-decor:0.2.2

Thanks

ebarrenechea commented 8 years ago

@notnotme Sorry for the huge delay in getting back to you. The header click functionality is still sitting in a branch (header_click), but I'll merge it and publish a new version (0.2.6) tonight. If you'd like to try it right away, you can use jitpack.io and checkout the branch snapshot which I believe it would be header_click-SNAPSHOT in this case.

notnotme commented 8 years ago

Thanks, it work now. Sorry for the delay to test the update you made.

ebarrenechea commented 8 years ago

Thanks! :+1: