问题
Hi I'm using MPAndroidChart and my added OnClickListener is triggered right after i zoomed into or dragged a chart. How can i disable this behavior?
This are my chart properties:
chart.setTouchEnabled(true);
chart.setScaleEnabled(true);
chart.setDragEnabled(true);
chart.setPinchZoom(true);
chart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//this only should run if i really click on the chart, not if i zoom or drag it.
...
});
Is there an easy way to do it? This ClickListener, ScaleListener and ScaleGestureDetector gang bang ist kinda complicated :/
thanks in advance
回答1:
Implement the ScaleGestureDetector
in http://android-developers.blogspot.com.tr/2010/06/making-sense-of-multitouch.html .
At onScale Event, remove the OnClickListener
with chart.setOnClickListener(null)
. Then Implement an OnTouchListener
and add onClickListener
at ACTION_UP
.
This should allow you to avoid triggering onClick events at pinch to zoom.
来源:https://stackoverflow.com/questions/31257322/disable-onclicklistener-while-scaling-or-dragging-a-view