[英]android how to detect click on canvas which is in a horizontal scrollview
Hi I have a horizontal scrollView and inside it I draw some arcs on canvas which gives me set of horizontally scrollable pie charts. 嗨,我有一个水平scrollView,在其中我在画布上绘制了一些弧形,这使我有了一组水平可滚动的饼图。 Now I need to handle the on click events of each of the pie charts, could some one help me regarding the same. 现在,我需要处理每个饼图的单击事件,有人可以帮我解决一下问题。
ChartUtility sampleObject=new ChartUtility(getActivity());
sampleObject.draw(new Canvas());
ChartContainerLayout.addView(sampleViewObject);//here chartcontainerlayout is a linear layout which his present in a horizontal scrollview.
I have tried the ontouch event of chartutility class. 我已经尝试过chartutility类的ontouch事件。 But what ever is the action(either a click/horizontal scroll), the event.ACTION is being returned as "down". 但是无论什么动作(单击或水平滚动),event.ACTION都将作为“向下”返回。 So how should I recognize the click event on individual items. 因此,我应该如何识别单个项目上的click事件。
I would put a LinearLayout with orientation set to horizontal into the HorizontalScrollView and then make each pie chart in a separate layout within that. 我将将方向设置为水平的LinearLayout放入HorizontalScrollView中,然后将每个饼形图放置在其中的单独布局中。 Then set listeners on those layouts. 然后在这些布局上设置侦听器。 I would not have the click handling mixed with the scrolling. 我不会将单击处理与滚动混合在一起。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.