Questions tagged [android-event]

On Android, there's more than one way to intercept the events from a user's interaction with your application. When considering events within your user interface, the approach is to capture the events from the specific View object that the user interacts with. The View class provides the means to do so. Questions that regard doubt about any type of events action (listeners and handlers), should use this tag to express themselves.

Within the various View classes that you'll use to compose your layout, you may notice several public callback methods that look useful for UI events. These methods are called by the Android framework when the respective action occurs on that object. For instance, when a View (such as a Button) is touched, the onTouchEvent() method is called on that object. However, in order to intercept this, you must extend the class and override the method. However, extending every View object in order to handle such an event would not be practical. This is why the View class also contains a collection of nested interfaces with callbacks that you can much more easily define. These interfaces, called event listeners, are your ticket to capturing the user interaction with your UI.

While you will more commonly use the event listeners to listen for user interaction, there may come a time when you do want to extend a View class, in order to build a custom component. Perhaps you want to extend the Button class to make something more fancy. In this case, you'll be able to define the default event behaviors for your class using the class event handlers.

For a more detailed information you can visit Google oficial webpage about Events at Google Developer - Events

318 questions
4
votes
2 answers

How to stop other images to move while dragging of one image

In my application i am able to overlap images one by another, when i drag one image from the group of images the left and right images are also moving on the screen. How restrict this, below is my code int cards[] =…
Vamshi
  • 1,495
  • 1
  • 15
  • 31
4
votes
1 answer

Why motionEvent.getX() return inconsistent values, when using setScaleX()?

I've child view resides in a ViewGroup. I'd like to scale (zoom) the child with a pinch. I'm using setScaleX/Y() to scale the child. The scale is calculated form distance between 2 pointers, in OnTouch(). But when I set the scale of the child it…
4
votes
2 answers

toggle button event not working on various devices

I am testing my application on various models and I have realized that the toggle button ON and OFF event is not working. This is the list of devices: Samsung YS5360 Samsung Galaxy Note Samsung S Plus HTC Sensation XE HTC Wildfire S Motorola…
user788511
  • 1,726
  • 2
  • 30
  • 52
4
votes
3 answers

Setting frequency attribute RRULE to run the event once

I have Intent intent = new Intent(Intent.ACTION_EDIT); intent.setType("vnd.android.cursor.item/event"); intent.putExtra("beginTime", dateStart.getTime()); intent.putExtra("allDay", false); intent.putExtra("rrule",…
AndreaF
  • 11,975
  • 27
  • 102
  • 168
4
votes
2 answers

Capturing touch events in an android list item and prevent scrolling

I'm trying a wild idea here by putting a custom control within the items of a certain list view. The control is only "activated" if the user touches down on a certain trigger point and then they can "drag around." My question is, what can I do in…
cemulate
  • 2,305
  • 1
  • 34
  • 48
3
votes
1 answer

how to deal with the onclick event when two view overlapping

i use layoutparams to set the position of a few views, some are overlapped. when i touch the overlapped part, both the two views which include the overlapped part corresponded to the touch event! but i just want the above one to correspond to, can…
ziyao_zou
  • 31
  • 3
3
votes
4 answers

What Android event is only called once until the activity is destroyed?

I'm looking for a single answer (but I might be asking the wrong question) Question- does any event only get called once TOTAL until an activity is destroyed? I ask because when my user rotates the phone to landscape oncreate and onstart are both…
Toran Billups
  • 27,111
  • 40
  • 155
  • 268
3
votes
2 answers

Let parent View assume MotionEvents if child returns false

I have a application that need event handling on a unusual way. For my question, let me first explain a simple case that the current event handling system of Android don't fits for me. Supposing that I have a FrameLayout (that I'll call ViewSwiper…
Marcos Vasconcelos
  • 18,136
  • 30
  • 106
  • 167
3
votes
1 answer

Android Architecture Components

I am using MVVM android architecture for my application. I want to implement click event, so, do we need to use data binding architecture components or we can just use activity for handling the click event and validating the user inputs? What's the…
3
votes
3 answers

Continue onScroll event after onLongPress

Does anyone know how to combine onLongPress(MotionEvent e) and onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)? Idea is to start with onLongPress but continue with sliding across some view. Current code i have: private…
RadoVidjen
  • 432
  • 7
  • 17
3
votes
1 answer

Handling TouchEvents on RecyclerView

I have this code which implements a RecyclerView and I want to add to it some gestures. I want 2 things to do and I don't know because I'm new to this. When someone clicks on RecyclerView I want to catch the event from the Activity before goes down…
Nick
  • 2,818
  • 5
  • 42
  • 60
3
votes
1 answer

How to compare MotionEvent downtime to a clock, what is its time basis?

I am trying to determine the chronological ordering of a MotionEvent vs something that happens periodically in my UI object. private var rotateFinishTime: Long = -1 .... fun somethingHappensPeriodically() { Log.d(tag_, "show new round") ... …
androidguy
  • 3,005
  • 2
  • 27
  • 38
3
votes
2 answers

Listen Android back button in cocos2d-x

I want to track android back button in android activity. I have all ready work on back button in onKeyReleased() in C++ , but when I check back button in activity methods like onBackPressed() , onKeyUp() , OnKeyDown() e.t.c then I get…
3
votes
1 answer

Prevent widget onUpdate onReceive while dragging it from widgets list?

I have onUpdate and onReceive for my widget they work fine. But my problem is that they are being triggered when I dragged widget from widgets install list to android home screen is there anyway to prevent this behavior? This are my methods: public…
3
votes
1 answer

Choose a Location on mapview on view Touch

in my app, I want the user to choose a location on a map with tapping on a view that is on top of MapView. this is my code: map_fragment.xml
ReZa
  • 1,273
  • 2
  • 18
  • 33
1 2
3
21 22