I've got a big headache and spent a few hours to solve my problem withou any reasonable results.
I use a custom adapter (extending ArrayAdapter
) to show listview items. This adapter implements OnTouchListener
. There's also a background selector which color is changing when an item is touched and OnItemClickListener
in ListViewActivity
.
What I need is capture touch events (all of them, not only ACTION_DOWN
) in the adapter. When onTouch
returns false, the consecutive events (ACTION_CANCEL
, ACTION_UP
etc.) aren't captured. On the other hand returning true stops dispatching all other events (e.g. click) so that the ListViewActivity's onItemClick
is never triggered.
I tried hard to find any working solution in SO and other resources, but with no success.
One idea was not worry about click events and background. I may set the background programatically and trigger click event the same way when the onTouch
action is ACTION_UP
, but view.performClick()
does nothing (view is the 1st argument of onTouch
method).
[EDIT]
To make it clear, I want to handle touch events in the adapter beacuse I need the textview in the item to marquee when the user touches it. Thus, in onTouch
, when the action equals ACTION_DOWN
, I assign true
to setSelected property of the textview and, consequently, false
when ACTION_CANCEL
or ACTION_UP
.
Any suggestions?
Thanks in advance.