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
2
votes
1 answer

Change parent's background color when its child is clicked

I have a TableRow which contains a LinearLayout, and then this LinearLayout contains a TextView. What I want is, once the TextView is clicked, the entire TableRow would change its background color. I've tried to use getParent() and performClick() to…
Jiechao Wang
  • 922
  • 1
  • 15
  • 32
1
vote
1 answer

How to handle Contacts changes in Android?

I want to listen for Contacts changes. How do I do that?
1
vote
3 answers

Spinner animation during long operations

My app has a not that frequent operation that is executed on the UI threads and takes long time (up to 3 secs). I want to display an animated 'wait' indications during that time. For example, a rotating spinner. No need to display the actual…
1
vote
1 answer

How to distinguish Click event from touch event in onTouchEvent method when app is running in device?

I override the onTouchEvent method of Activty. In this method i would like to listen to actions: touch and click and give them two different reactions. The problem is when i test my app in emulator, everything works fine. But not in device. As in…
Frank Cheng
  • 5,928
  • 9
  • 52
  • 80
1
vote
2 answers

Back button reopens the Activity

There are a few times when the user presses the back button on my app, and unfortunately he doesn't get out; the activity slides, but behind it there is exactly the same one...How is that possible? How could I avoid it? should I implementate…
user1012480
  • 752
  • 2
  • 11
  • 24
1
vote
1 answer

Event when scrolling is done

In a ScrollView (Vertical or Horizontal) how to know when the scroll animation is done? I start the animation with smoothScrollBy or smoothScrollTo
Marcos Vasconcelos
  • 18,136
  • 30
  • 106
  • 167
1
vote
0 answers

Can an Android Service detect if an event was consumed by App or not?

I am running an Android application. An event happened (i.e. user double pressed the home key). There can be two possibilities, The application consumed the event and passed (or restrict passing) to the lower layer The application did not consumed…
Sazzad Hissain Khan
  • 37,929
  • 33
  • 189
  • 256
1
vote
2 answers

How to properly support click on selectable textview in Android

I have a LinearLayout with a selectable text view
1
vote
0 answers

How to show Alert Dialog when the activities are in transition phase from one activity to another?

I have an activity called LoginActivity, where in user explicitly logs into the app using username and password. When he logs in I want to register him for push notifications by sending his device token to server. Once his device token in sent to…
1
vote
0 answers

How do I trigger an onClick event when a finger goes outside the button in the screen during long click

public boolean onLongClick(View arg0) { Toast.makeText(getContext(), "long click", Toast.LENGTH_SHORT).show(); return false; } public void onClick(View arg0) { Toast.makeText(getContext(),…
1
vote
2 answers

How to Stop Event's While Animation is in process?

I am working on Animating my view where i animate the translation and scaling of View. Problem: If my animation duration is for 2000 ms (2 Sec) i don't want any user event's to interfere in between animation. Example if Double Tap on View Trigger's…
Anmol
  • 8,110
  • 9
  • 38
  • 63
1
vote
1 answer

why can use getParent ().RequestDisallowInterceptTouchEvent (true) disallow Intercepted

@Override public boolean dispatchTouchEvent(MotionEvent ev) { // why this code can be executed. getParent().requestDisallowInterceptTouchEvent(true); return super.dispatchTouchEvent(ev); }…
Guo
  • 1,761
  • 2
  • 22
  • 45
1
vote
0 answers

How can I capture SCREEN_OFF/ON event when the app is idle?

For a proof of concept, I need to be able to capture whether the phone gets interactive, and the other way around. So far, I tried following methods: with BroadcastReceivers capturing SCREEN_OFF and SCREEN_ON events, but this only works when the…
danimart
  • 13
  • 3
1
vote
1 answer

Android Remove Background property in Image view

I am added a background image highlight in RecyclerView Image: but when i click the image previous selected image highlight is also shown. how to fix this. my code is holder.colorImage.setOnClickListener(new View.OnClickListener() { …
1
vote
1 answer

Android calendar deletes calendar and events after 10 minutes

I've been working on an app that involves making events. I've successfully created a calendar on the default calendar on Android, and I've been able to add, delete, or update events on this calendar. However, I noticed the calendar I create gets…
dk31
  • 23
  • 5