touch-event

onTouch, onLongClick together in android

拈花ヽ惹草 提交于 2019-11-29 10:37:14
I'am adding imageviews to parent layout dynamically. And i'am performing zoom in/out operations onTouch of added image. I want to remove the added view onLongPress of it. img.setOnLongClickListener(longClickAction); img.setOnTouchListener(touchAction); onLongPress : OnLongClickListener longClickAction = new OnLongClickListener() { @Override public boolean onLongClick(View v) { parentLayout.removeView((ImageView)v); return false; } }; onTouch : OnTouchListener touchAction = new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { ImageView i = (ImageView)v; /

iOS - Can an app running in the background send touch / gesture events to another app in the foreground?

给你一囗甜甜゛ 提交于 2019-11-29 08:50:08
I have been asked to develop an app that will record and later "play back" touches and gestures onto another app running in the foreground. From my experience and knowledge, this is not possible unless both apps are setup to send/receive data between them through notifications or other methods. Also, it would be a huge risk for apps and their data to be exposed to anybody. I am 99% sure this is not possible, but was just curious if anyone else has come across something similar (or documentation that specifically states this is forbidden). Nope not possible, no way no how, dont even try.

In onTouchEvent, ACTION_UP doesn't work

你离开我真会死。 提交于 2019-11-29 06:00:56
I'd like to read when a player touches the screen, and when not. @Override public boolean onTouchEvent(MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_UP){ //ACTION UP actionOnUP = true; Log.v("MC", "Up"); } if(event.getAction() == 0){ //ACTION DOWN actionOnUP = false; Log.v("MC", "Down"); } Log.v("MC", event.getAction() + " "); return super.onTouchEvent(event); } This code, yes, it works, but only when player touch the screen (ACTION_DOWN), but when he don't touching the screen (ACTION_UP), nothing happens :/ ^ This is screen form LogCat. You can see: this is only ACTION_DOWN,

Pass touches to the view under

此生再无相见时 提交于 2019-11-29 05:25:31
In my app I have a fragment on top of the activity. The fragment is filling the whole screen. Part of the fragment is a transparent View and you can see the views under (that belong to the activity). Is there a way to transfer the touch events to the views that are under the transparent View of the fragment? Thanks! Maciej Boguta In your overriden onTouchEvent method inside the fragment return false , it passes the touch event to the lower layer views. mhdjazmati simplest way : from here : https://stackoverflow.com/a/34436589/3818437 Declare your fragment not clickable / focusable by using

How to detect single touch as well as multi-touch in onTouchEvent()

梦想的初衷 提交于 2019-11-29 03:40:06
问题 I used the following code to detect the single finger touch and double finger touch. The code detects the double finger touch (when count==2 ). I need to do some action on single touch also. If I touch the screen with one finger it doesn't go for the else part. What have I done wrong in this code? @Override public boolean onTouchEvent(MotionEvent event) { int action = event.getAction() & MotionEvent.ACTION_MASK; switch (action) { case MotionEvent.ACTION_POINTER_UP: { int count = event

how to swipe a button onTouch event in android

拈花ヽ惹草 提交于 2019-11-29 02:42:19
How to swipe a button on touch event android with directions left,right, up,down..?...I am new to android and want to develop a callback application.Please help by providing some links callbackButton.setOnTouchListener(new OnTouchListener() { private float currX; private float currY; @Override public boolean onTouch(View v, MotionEvent event) { float x1 = 0, x2, y1 = 0, y2, dx, dy , oldx =0,oldy=0; String direction; switch(event.getAction()) { case MotionEvent.ACTION_DOWN: oldx = event.getX(); oldy = event.getY(); break; case MotionEvent.ACTION_MOVE: x2 = event.getX(); y2 = event.getY(); dx =

Catch onTouch event by parent, handle it and pass to children

亡梦爱人 提交于 2019-11-29 01:15:11
I tried to understand how Android handle touch event and got a little bit confused. From what I understand touch event are send to the root view and pass down to the children. I have a FrameLayout that is a container for Fragment . First fragment view is a ScrollView , second one is some kind of Gallery (HorizontalListView) and the last one is also FrameLayout . Only one fragment in the layout each time. What I want to do is to identify user swipes on the screen, for the app use. I want to count the swipes and do something after some number of swipes. I tried to put a OnTouchListener on the

Android: ItemizedOverlay onTouchEvent and onTap overlapping

心不动则不痛 提交于 2019-11-29 00:40:25
I am trying to place a marker on a map overlay and then present a dialog when the user selects the drawable. The problem is the events seem to overlap. After I click the map and the marker is drawn, the onTap fires immediately afterwards, and because I have just drawn the marker, it is directly under the onTap event, so my dialog always fires. Does anyone have any suggestions on how to make these events mutually exclusive? Here is the code for the map activity: public class SelectGameLocation extends MapActivity implements GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener

Is there a touch method for UILabel?

走远了吗. 提交于 2019-11-29 00:21:34
问题 I'd like to do an action if someone touches a predeclared UILabel , something like: if (label is touched) { my actions; } Is there a method/way to do that? 回答1: You could use a gesture recognizer: - (void)someSetupMethod { // ... label.userInteractionEnabled = YES; UITapGestureRecognizer *tapGesture = \ [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapLabelWithGesture:)]; [label addGestureRecognizer:tapGesture]; [tapGesture release]; } - (void)didTapLabelWithGesture:

How to handle Touch Events on a Fragment?

南笙酒味 提交于 2019-11-28 19:07:50
I'm building an interface where I need to process touch events . In particular I would to be able to enable them only to a confined area in a fragment. To better understand the problem, to respect the standards and for the goal of my application, I planned the navigation drawer, which assumes the presence of many fragment (instead of activities). An activity with touch events is implemented quite easily, on the other hand I have read on the internet that with the fragments can become a problem . My application, at the architectural level, is as follows: - MainActivity.java - NavigationDrawer