touch-event
Add Marker on Android Google Map via touch or tap
Try using new Google Map API v2. It’s easy to use and you can add a marker on tap like this: map.setOnMapClickListener(new GoogleMap.OnMapClickListener() { @Override public void onMapClick(LatLng point) { allPoints.add(point); map.clear(); map.addMarker(new MarkerOptions().position(point)); } }); or in Kotlin: map.setOnMapClickListener { allPoints.add(it) map.clear() map.addMarker(MarkerOptions().position(it)) } Note that you might want to remember all your added … Read more
How to add a gesture detector to a view in Android
This example shows how to add a gesture detector to a view. The layout is just a single View inside of an Activity. You can use the same method to add a gesture detector to any type of view. We will add the gesture detector to the green View. MainActivity.java The basic idea is to … Read more
Method onTouchEvent not being called
I found a perfect solution. I implemented new method: @Override public boolean dispatchTouchEvent(MotionEvent event) { View v = getCurrentFocus(); boolean ret = super.dispatchTouchEvent(event); and now it all works fine! Edit: My final code: @Override public boolean dispatchTouchEvent(MotionEvent event) { View v = getCurrentFocus(); if (v instanceof EditText) { View w = getCurrentFocus(); int scrcoords[] = … Read more
checking if touchend comes after a drag
Use two listeners: First set a variable to false: var dragging = false; Then ontouchmove set dragging to true $(“body”).on(“touchmove”, function(){ dragging = true; }); Then on drag complete, check to see if dragging is true, and if so count it as a dragged touch: $(“body”).on(“touchend”, function(){ if (dragging) return; // wasn’t a drag, just … Read more
Can’t get coordinates of touchevents in Javascript on Android devices
FINAL EDIT: Ok I got it working, if anyone finds this and has a similar problem you need to access the touch array within the event, and if just using a single touch (rather than multi touch) take the first item out of the array, as below, or you may need to offset it if … Read more
prevent touchstart when swiping
var touchmoved; $(‘button’).on(‘touchend’, function(e){ if(touchmoved != true){ // button click action } }).on(‘touchmove’, function(e){ touchmoved = true; }).on(‘touchstart’, function(){ touchmoved = false; });