问题描述:

I implemented the OnTouchListener for my Layout including every layout/widget in it and I was successfully able to retrieve the direction of the swipe and the ID of the widget/layout that received the swipe.

My question is if the user swiped on two or more different objects, for example he swiped from left to right on two buttons, the first button receives the touch event and I get the id of that button only. how can I retrieve all the ids of the objects on which the swipe was made (same as the swipe keyboard functionality)?

Is there a way to get the ID of every object that the user touched during his swipe movement by the X and Y of the touch event?

Thanks.

网友答案:

If i understand your Problem currently then you can do like below.

in OnTouch method of button use below code inside.

  LinearLayout mLinearlayout=(LinearLayout) v.getParent(); 

By this way you will get Button Parent View and now do process of getting Other View from Parent.Here i Use LinearLayout just for Example ,Because i have LinearLayout as parent of my Button View.

相关阅读:
Top