onClick binding inside a ListView item

64 views
Skip to first unread message

memdix

unread,
May 14, 2013, 4:34:57 AM5/14/13
to android...@googlegroups.com
I have an ImageButton in the item template of a ListView.
The ImageButton's "onClick" is binded to a Command.
The ListView's "onItemClicked" is binded to another Command.
When I click on the ImageButton the Command binded to the ListView is invoked instead of the one binded to the ImageButton.

Getting into OnClickViewEvent class I can see the registerToListener gets the ItemViewEventMark and registers it with high priority:

protected void registerToListener(View view) {
Binder.getMulticastListenerForView(view, OnClickListenerMulticast.class).register(this);
ItemViewEventMark mark = EventMarkerHelper.getMark(view);
if (null != mark) {
Binder.getMulticastListenerForView(view,OnClickListenerMulticast.class)
      .registerWithHighPriority(mark);
}
}

If I'm not wrong, this is why the onItemClicked Command is invoked. 
Now, is there a clean way to bypass this side effect?
What is the purpose of the ItemViewEventMark? Is it safe to remove the ItemViewEventMark mechanism from the OnClickViewEvent logic?

Have a nice day, thanks.

PS: it's been long since last update to Android Binding, is the library still alive? (Hope it is, I use it in all my projects)

Andy Tsui

unread,
May 19, 2013, 8:38:38 PM5/19/13
to android...@googlegroups.com
It's interesting that Github is not showing the activity of all
branch, but only the master branch if you logged on it.. so it looks
like the project is not moving :) We are currently on develop branch
indeed.

Regarding your question, that's a problem from the List View, if you
register something on ListView's onItemClick, then it will capture all
the children's on click without propagation. Solution? if you need
individual control on "click" on child, don't use onItemClick. You can
simulate this by adding onClick to the root of Child template, but the
only problem is you need to deal with the change of state manually.
> --
> You received this message because you are subscribed to the Google Groups
> "AndroidBinding" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to androidbindin...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
Reply all
Reply to author
Forward
0 new messages