简体   繁体   English

Android如何检测在水平scrollview中的画布上的单击

[英]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放入Horizo​​ntalScrollView中,然后将每个饼形图放置在其中的单独布局中。 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.

相关问题 在Android中,如何在ScrollView中检测Click和LongClick - In Android, how to detect Click and LongClick in ScrollView 为画布应用水平滚动视图 - apply the horizontal scrollview for canvas Android Scrollview:如何检测scrollview的开始和结束 - Android Scrollview : How to detect begin and end of scrollview 如何在水平ScrollView中为图像制作单击侦听器 - how to make click listener for images in horizontal ScrollView 如何检测画布上的点击和longClick - How to detect click and longClick on canvas 如何启用具有多列以适应 Android 中的水平滚动视图的表格布局? - How to enable a table layout which has many column to fit in a horizontal scrollview in Android? 如何用ANDROID中的scrollview实现水平滚动小部件? - How to implement horizontal scrolling widget with scrollview in ANDROID? 如何在Android的水平ScrollView中移动到下一张图像 - How to move to the next image in the horizontal ScrollView in android Android-禁用horizo​​ntalview作为子级的horizo​​ntalscrollview的水平滚动 - Android- disable horizontal scrolling of horizontalscrollview which has scrollview as children Android:在水平ScrollView中添加TextViews并检查哪个texview位于Center中? - Android: Add TextViews in Horizontal ScrollView and Check which texview is in Center?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM