I have a ScrollView -> Table => TableRow that I dynamically add Rows to, each row has a LinearLayout inside of it that I attach a OnTouchListener to and then when its touched I do something. At least that was the plan, the problem I am having is that when you scroll in the ScrollView, even while scrolling it fires off these events. This type of behavior does not occur for the other controls I have in the ScrollView such as Buttons, ImageButtons, EditText
My question is how do I get the LinearLayout to ignore these OnTouch events while the ScrollView is scrolling like the Button and EditText fields do?
Inside your onTouch event callback add an if statement or case block to that that checks for
(me.getAction == MotionEvent.ACTION_CANCEL)similar to this:It has been a long time since I worked on it, but I know I had to solve this problem at one point, and upon a quick glance just now I think this is what I had to do in order to get it working. It is going to keep receiving callbacks while the list is scrolling, but the action on them should be cancel. So if you set up some sort of if, or switch/case that checks for action_cancel and does nothing when it is true, from the users perspective the onTouch will “ignore” the events that happen while scrolling.