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

Detect touch event when onInterceptTouchEvent() used

I am asking this rather complex question hoping that i would get an idea from you. Here is the thing: I have created a custom list view class, the one above: public class FolderListView extends ListView { private float xDistance, yDistance,…
Adrian Olar
  • 2,883
  • 4
  • 35
  • 63
2
votes
3 answers

How to implement the call back mechanism between Activites

I have 2 activities first details activity and second activity page is confirmationPage,Once i confirm it should come back to first page,how should i handle this scenario? Is it possible between activities,instead of using fragments?
Rakesh
  • 14,997
  • 13
  • 42
  • 62
2
votes
1 answer

Android Event Propagation

The Android input event documentation here seems to imply that returning false in an event listener will cause the event to continue on to other listeners. For example OnTouchListener touchListener = new OnTouchListener() { @Override public…
William Seemann
  • 3,440
  • 10
  • 44
  • 78
2
votes
1 answer

Add gesture listener to child view without hiding parent's touch event

I want to have an overlay view to receive gesture events but still keep receiving onTouch event of parent(below) view. However, The gesture in child view seems hide parent onTouch event. Layout
Cuong Thai
  • 1,165
  • 1
  • 11
  • 24
2
votes
0 answers

How to find mapping between buttons and callback methods?

I want to dynamically analyze an android application like yelp for security purposes. I would like to find out if multiple items in the list view correspond to the same callback; if they do, I will not click these items during dynamic analysis. Is…
Priyank Desai
  • 3,693
  • 1
  • 27
  • 17
2
votes
1 answer

dispatch touch events from gesture listener onSingleTapConfirmed and keep selector effects

I have a list view with items containing multiple buttons. The layout for one item looks something like this: I have an overlaying transparent view, covering each entire list item. This view listens to two gestures: onDoubleTap and…
Richard
  • 14,427
  • 9
  • 57
  • 85
2
votes
1 answer

Alternative to CalendarContract in Android API 8?

My application needs the functionality to add Events into internal phone Caledar. In API 14 it is possible via CalendarContract with smth like the code below. What would be an alternative in API 8? Or is it possible to detect the API in code and…
exomen
  • 355
  • 2
  • 6
  • 20
2
votes
2 answers

NullPointerException for OnClickListener in certain phones

I'm getting a NullPointerException at this line: ImageButton sb = (ImageButton) findViewById(R.id.imageButton2); sb.setOnClickListener(new OnClickListener() { //error on this line public void onClick(View v) { Intent intent = new…
Mohammad Shabaz Moosa
  • 1,515
  • 1
  • 13
  • 20
2
votes
3 answers

Can't get ListView item selected

I am trying to learn how to receive a notification on a click on a radio button in a ListView but nothing comes back when I click on a radio button next to a ListView item. Below is the code where I set up the listener. I am doing this in an…
Dave
  • 873
  • 2
  • 15
  • 27
2
votes
3 answers

How to implement an AlertDialog.Builder selected item click event?

I want to implement AlertDialog.Builder selected items click event. Below is what I have tried so far. I'm quite new to Android and I'm not sure how to access that event. How to implement the click event for each individual item in the list? import…
not 0x12
  • 19,360
  • 22
  • 67
  • 133
2
votes
1 answer

Accessing default calendar id

I am working on a application which set the events and reminders in calendars. The code i used for it is as follows. private void addReminder(int statrYear, int startMonth, int startDay, int startHour, int startMinut, String title){ Calendar…
Manoj Fegde
  • 4,786
  • 15
  • 50
  • 95
2
votes
3 answers

Capturing system event in an Activity

I'm planning to have a button in an activity which will start a service when clicked. However, GPS needs to be enabled for the service to do its work so I'd like to have the button disabled if GPS is disabled. Is there a way to get android to notify…
zoran119
  • 10,657
  • 12
  • 46
  • 88
2
votes
3 answers

onclicklistener for subitems of listview

I have a listview and each item of the lisview is a linearlayout. Each one of the linearlayouts contains 3 textviews. How do i set a onclicklistener for those textviews? i tried this: TextView…
2
votes
1 answer

Android send data from activity to activity using bundle

i have to activities AnswerQuestion.java and SendAnswerToServer.java, and i want to send data from first activity to another one on the AnswerQuestion activity i write this: Bundle basket = new Bundle(); basket.putString("time",…
user1476841
  • 79
  • 1
  • 10
2
votes
2 answers

Is there a cleaner approach to click listeners in Android?

So I have been developing in Android for quite some time and I am natively a .Net developer. The problem I am facing is that my code looks awful, and I really dislike the way that Java\Android not sure which, makes click events appear in code. In…
Steven Combs
  • 1,890
  • 6
  • 29
  • 54