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

How to fix duplicate data when use Fragment and TabLayout in Android

I want show website datas in 3 fragments with json! when swipe between TABs not duplicate datas. but when click on TABs, duplicate previous data again! For send data from from AsyncTask to Fragments i use EventBus component. Fragment codes: public…
0
votes
0 answers

Adding event with reminders to calendar using intent

I've transferred my data to new activity -> from HotelListAdapter.java to HotelPage.java I set Log to be sure the Data have been transferred successfully. Log is working now and show my variables value , but my TextView and ImageView do not display…
Mohammadreza
  • 56
  • 2
  • 13
0
votes
1 answer

Get last Android System shutdown time from API

Is there a way to get the last Shutdown time using Android API or any Android log? I know I can use ACTION_SHUTDOWN event with a BroadcastReceviver to store the date of the shutdown, but I just want the time when the last shutdown occurred and I…
0
votes
0 answers

android - How to handle all onTouch events in child and parent

I hava RecyclerView with custom views, which handle onTouch event and do some work when ACTION_UP handled. Also I want to get gestures and handle onTouch event in my root view. I need to handle full event: ACTION_DOWN ... ACTION_UP in both of my…
Alexey Markov
  • 1,546
  • 2
  • 23
  • 41
0
votes
1 answer

Android ProgressDialog.show not showing up

I have the following code. When I put it in the ACTION_DOWN it works, when I put it in the ACTION_UP is doesn't, what am I doing wrong? button1.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View view, MotionEvent…
Adroid Freak
  • 329
  • 3
  • 18
0
votes
4 answers

Android onStart() event is called when the screen is turned off

I got an Android app which needs to load some data from a website and then display it. For that purpose, the user gets shown a loading bar, in a background thread loads the website and then it switches back to the main thread (with a Handler) and…
Namnodorel
  • 385
  • 5
  • 17
0
votes
1 answer

Detecting whether touch event has occurred in android?

I am developing an android application, in which, I am changing the image continuously in intervals. Before every change, I need to check if touch event has occurred or not? If yes, then which event has occurred, DOWN or UP? In my search I only…
rambo
  • 36
  • 6
0
votes
0 answers

What is the most idiomatic way to show a retry button when the receiveError event happens on a WebViewClient?

I would like to show a retry button when my application cannot load a page. As far as I understand, whenever this happens, the onReceiveError() method on WebViewClient is called. I have a piece of code that does an animation. It makes a button…
Parham Doustdar
  • 2,019
  • 3
  • 22
  • 41
0
votes
2 answers

How to handle navigation drawer's event in another activity?

I have a main activity with a lot of fragments. I have implemented the navigation drawer inside the main activity so that when I am viewing the fragments, I can open the navigation drawer as well. Inside the main_activity.xml layout file (refer…
karansky
  • 538
  • 1
  • 4
  • 24
0
votes
1 answer

How to load XML feed data into user interface with an splitted "getData" and "MainActivity" without freeze UI

I'am new with android an read a lot about the life cycles and so on on developer.android.com Now i wanna build an app that gets data from an online XML feed. I created an XmlManager class which extends the aSyncTask<...> Here i download the XML…
CodeNinja
  • 836
  • 1
  • 15
  • 38
0
votes
1 answer

Set num lock state on a hardware keyboard

Trying to set the num lock state to either always on or always off for an app. I'm guessing I can intercept the numlock press to keep the state, I'm just not sure how to set the initial state. Is there a way I can press the num lock key virtually?
0
votes
1 answer

Why does getLayoutParams() throw exception when called inside some events? e.g., onSaveInstanceState

I have a RelativeLayout with a one View object (a simple bitmap). I use getLayoutParams() and setLayoutParams() to move it, for the sake of compatibility. But when getLayoutParams() is called from inside onSaveInstanceState() event (because screen…
oscar
  • 355
  • 1
  • 2
  • 13
0
votes
1 answer

Get the real X/Y position of an onTouch Event

I know there are some similar topics that have been posted, but I couldn’t find a good solution for my problem. I have a GridView which is filed with a custom ImageAdapter. Everything works fine, but whenever I click on an image contained in the…
0
votes
2 answers

Can I add event to calendar without letting user know in android?

I want to add event to my native calendar using the below code. and it is working fine. SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm"); final Calendar cal = Calendar.getInstance(); try { …
karan
  • 8,637
  • 3
  • 41
  • 78
0
votes
1 answer

Keyboard show/hide event not firing in Cordova 5.1.1

I just updated my cordova from 4.3.0 to 5.1.1 and it seems that the keyboard event is not firing up previously, document.addEventListener("showkeyboard",function() { } and document.addEventListener("hidekeyboard",function() { } where…