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
1
vote
3 answers

Consistency of onTouch event.getX or Y on different screen sizes - Android

I'm implementing an OnTouchListener on a custom view. In this view I'm drawing an object that basically moves along x and y axis I get form event.getX(); and event.getY(); respectively. I want to perform some draw changes when touch events happen…
1
vote
2 answers

android create textViews in tableRows programmatically

I have these three lists with the same number of elements ListcompetitoinsIDs = new LinkedList(); Listmarks = new LinkedList(); ListnumOfQuestions = new LinkedList(); I want to put the first element…
William Kinaan
  • 28,059
  • 20
  • 85
  • 118
1
vote
1 answer

Android change time of countDownTimer

my application is questioning/answering application, client/server, the client is android application, and the server is java tomcat server application i want the user to answer any question in 25 seconds, but i will give him time to read the…
William Kinaan
  • 28,059
  • 20
  • 85
  • 118
1
vote
1 answer

Android startActivity with intent doesn't work

i have a countDownTimer , and it fisish the time i want to go to an error screen this is the code for countDownTimer timer = new CountDownTimer(36000, 1000) { @Override public void onTick(long millisUntilFinished) { …
user1476841
  • 79
  • 1
  • 10
1
vote
1 answer

Android LinearLayout make button doesn't work

I have many buttons in my layout and they work well. I want to put the two buttons on the same row, so I make a LinearLayout horizontal, but when I do that, the second button's click event doesn't work. It doesn't show me my textview
user1476841
  • 79
  • 1
  • 10
1
vote
2 answers

Item not clicked on a GridView

I have a GridView whose items are ToggleButtons, and I defined an event listener for clicks on items, but nothing happens when I click on them. Here's the listener: paintActionsGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() …
user940016
  • 2,878
  • 7
  • 35
  • 56
0
votes
2 answers

Android - Call an xml layout file in a class that extends View

I want to call my XML layout file in a class that extends view. I can't perform oncreate function in that because it does not extends Activity. My events are in the one class file and I am calling that class in another class file; but I want to…
omkar patade
  • 1,442
  • 9
  • 34
  • 66
0
votes
2 answers

single and long press not working after implementing onclick listener for imageButton in listView On android

I have List view on android with [TextView TextView ImageButton]. i implement the list view by using ArrayAdapter. as per my requirement i need single and long press event for list view,so that i use registerForContextMenu(getListView()) for long…
M.A.Murali
  • 9,988
  • 36
  • 105
  • 182
0
votes
1 answer

How to pause a moving object in android

I am developing an android game. in this i have two moving images on the screen, am able to drag this images, but my further requirement is to pause the image when i touch the image. am not finding any event to pause the image , and than restart…
Romi
  • 4,833
  • 28
  • 81
  • 113
0
votes
0 answers

How is "MotionEvent... recycled twice!" possible?

ScaleGestureDetector scaleGestureDetector = new ScaleGestureDetector(getActivity(), new ScaleListener()); relativeLayoutCell.setOnTouchListener((v, event) -> { scaleGestureDetector.onTouchEvent(event); } private class ScaleListener extends…
Hong
  • 17,643
  • 21
  • 81
  • 142
0
votes
0 answers

How to reconstruct the MotionEvent from raw event log

Is there any way to reconstruct the MotionEvent from the raw event log like this [ 75895.529710] EV_KEY BTN_TOUCH DOWN [ 75895.529710] EV_ABS ABS_MT_SLOT 00000000 [ 75895.529710] EV_ABS ABS_MT_TRACKING_ID …
Carpemer
  • 237
  • 2
  • 9
0
votes
1 answer

How can I detect the onFling event in Android?

Based on various examples I've found around the internet, I've got this as my code to pick up "swipes" (onFling AFAICT) However the only event handler that seems to be called is the onTouchEvent of GameView itself. I'm getting the messages logged by…
interstar
  • 26,048
  • 36
  • 112
  • 180
0
votes
1 answer

Local alarm for a foreground service?

I have a foreground service and while it's active I want to run some events based on specific exact time that you a user previously set, it can be one time or it can repetitive every day for example. I don't want to use AlarmManager because it…
user924
  • 8,146
  • 7
  • 57
  • 139
0
votes
1 answer

How to get view with x and y position on Android

I am trying to get view in dispatchTouchEvent(). However, this only passes MotionEvent. It has x and y position. But, it doesn't pass view itself. I can get view with currentFocus. However, this gets view after having a focus. And when you touch…
c-an
  • 3,543
  • 5
  • 35
  • 82
0
votes
0 answers

Android calendar add recurrence event but only effect for a short time

im testing android calendar recurrence event. Im have setted an event to android calendar and add a rrule, code like this: public static int addCalendarEvent(Context context, CalendarEvent calendarEvent) { checkContextNull(context); …
henry
  • 25
  • 4