Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
28 views
10 pages
03.1 Event Handling - 1X2
Uploaded by
niyaca4113
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save 03.1 Event Handling - 1X2 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
28 views
10 pages
03.1 Event Handling - 1X2
Uploaded by
niyaca4113
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save 03.1 Event Handling - 1X2 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save 03.1 Event Handling - 1X2 For Later
You are on page 1
/ 10
Search
Fullscreen
Event Handling Dr. Harshad Prajapati 14 June 2023 Event Handling e Event handling involves three things: Source (generates event): m Android component (generally Ul) that generates an event when some changes happen, e.g., user clicks. Event handler (handles event): PRN e SM eae ht cence Run Cuaect CMR MEST Tu on ovale sXe) Ure ele) A AMT Le ML Lele Ceo Ceo eee ea Celok e We already know event handling in Java.Event handling in Java ® XListener interface specifies contract(s) for event handling logic. For example, ActionListener specifies actionPerformed(ActionEvent e) as a contract. e Button (java.awt.Button) component is a source that generates event. e Registration of event handling logic (implementation of ActionListener, romeo MMe RTT GReN cues cers) For example, using button.addActionListener(alObj); In place of alObj (action listener object), we can pass an anonymous object of an anonymous class that implements ActionListener. Event handling in Java mare U1 oleae? (mn asec btnSubmit.addActionListener(new ActionListener() { public voj actionPerformed(ActionEvent ae){ Jlevent handling logic ) ea ticoy Searcy venaEvent Handling in Android ® Event handling in Android is done in similar way. e Example of event source: android.widget.Button e Example of event handler: Implementation of View.OnClickListener: CMe lae ol AWA One em) nae UA Soa) contract between event source and event handler. e Example of event registration: btnSubmit.setOnClickListener(object of View.OnClickListener) Method names for registration e Java uses method names starting with addXListener. The word add indicates, we can register more than one listener with event source for the same event. e Android uses method names starting with setXListener. The word set indicates, we can register exactly one listener with event source for the same event. If event handler was already registered, it would be replaced by the new one on calling setXListener.Listeners in Android classes are Static Cees aeolian ie cee MUS) al ma CAC el) Ce associated class. e Any inner interface in Java is static by default. Such interfaces are implicitly static even if static keyword is not used. © Static inner interfaces can be accessed directly using the enclosing class name. We do not require an instance of the enclosing class. Miia ROMO -en el (oe) ama CnCleeNCl Clen CU) Tatil SRR m View.OnClickListener. Some Widely Use Listeners ¢ View.OnClickListener: It handles click events on a View. The event handling method is onClick(View v) e View.OnLongClickListener: It handles long-click events on a View. The event handling method is onLongClick(View v)Some Widely Use Listeners CAC Melon a Cp It handles touch events on a View. Event handling methods are m onTouch(View v, MotionEvent event) onDoubleTap(MotionEvent e) onSwipeDown() onSwipeLeft() onSwipeUp() onSwipeRight() Some Widely Use Listeners e ScaleGestureDetector.OnScaleGestureListener: It handles events related to gestures. (E.g., pinch zoom in/out) Event handling methods are m onScale(ScaleGestureDetector detector): * lItresponds to scaling events for a gesture in progress. m= onScaleBegin(ScaleGestureDetector detector) PM ees NCR ICN ClaTteReme Reet Re ssi) m onScaleEnd(ScaleGestureDetector detector) e Itresponds to the end of a scale gesture.Some Widely Use Listeners © ScaleGestureDetector.OnScaleGestureListener: Bede selneT creh RUHR unl ite Regs cig m One onScaleBegin() mu Zero or more onScale() m One onScaleEnd() Some Widely Use Listeners e AdapterView.OnltemClickListener: Hala Talel [mel aa oe ae =) ACU oe oi SA GridView. The event handling method is onltemClick(AdapterView> parent, View view, int position, long id) e DatePickerDialog.OnDateSetListener: Handles the selection of a date in a DatePickerDialog. The event handling method is onDateSet(DatePicker view, int year, int month, int dayOfMonth)Some Widely Use Listeners © TimePickerDialog.OnTimeSetListener: It handles the selection of a time in a TimePickerDialog. The event handling method is onTimeSet(TimePicker view, int hourOfDay, int minute) e TabLayout.OnTabSelectedListener: It handles tab selection events in a TabLayout component. Event handling methods are m onTabSelected(TabLayout.Tab tab) m onTabUnselected(TabLayout.Tab tab) = onTabReselected(TabLayout Tab tab) Some Widely Use Listeners e ViewPager.OnPageChangeListener: It handles page change events in a ViewPager. Event handling method are m_ onPageSelected(int position) m onPageScrolled(int position, float positinOffset, int PSM ise ancl) m onPageScrollStateChanged(int state)Some Widely Use Listeners e CompoundButton.OnCheckedChangeListener: It handles events related to RadioButton and CheckBox. The event handling method is m onCheckedChanged(CompoundButton buttonView, boolean isChecked) Some Widely Use Listeners e TextWatcher: It is a standalone interface. Haar Walel enero OM mela y ce Event handling methods are mu beforeTextChanged(CharSequence s, int start, int count, int after) m onTextChanged(CharSequence s, int start, int before, int count) = afterTextChanged(Editable s)Event Registration methods for any View (Button, TextView setOnClickListener: Callback when the view is clicked. setOnDragListener: Callback when the view is dragged setOnFocusChangeListener: Callback when the view changes focus. setOnGenericMotionListener: Callback for arbitrary gestures. setOnHoverListener: Callback for hovering over the view. setOnKeyListener: Callback for pressing a hardware key when view has focus. setOnLongClickListener: Callback for pressing and holding a view. setOnTouchListener: Callback for touching down or up on a view. Event Registration methods for AdapterView setOnltemClickListener: Callback when an item contained is clicked. setOn|temLongClickListener: Callback when an item contained is clicked and Lato setOnltemSelectedListener: Callback when an item is selected.Event Registration methods for EditText PME MSO ile ee Mc erl Cala un eNom ee TlueReurlteceh e setOnEditorActionListener: Callback when an action button on the soft keyboard is pressed. oie oaLero) e https://guides.codepath.com/android
You might also like
Android Event Handling
PDF
No ratings yet
Android Event Handling
13 pages
Advance Java Chapter 3 Full Notes - Ur Engineering Friend
PDF
No ratings yet
Advance Java Chapter 3 Full Notes - Ur Engineering Friend
20 pages
Advanced UI Programming
PDF
No ratings yet
Advanced UI Programming
16 pages
Android - Event Handling: L. Grewe
PDF
No ratings yet
Android - Event Handling: L. Grewe
17 pages
Mcad - Unit 4
PDF
100% (1)
Mcad - Unit 4
40 pages
GUI - Event Handling (2) - Lecture
PDF
100% (1)
GUI - Event Handling (2) - Lecture
38 pages
Unit 8 Event Handling
PDF
No ratings yet
Unit 8 Event Handling
37 pages
Delegation Event Handling
PDF
No ratings yet
Delegation Event Handling
192 pages
Event Handling in Java
PDF
No ratings yet
Event Handling in Java
103 pages
Mobile
PDF
No ratings yet
Mobile
70 pages
Java Event Handling
PDF
100% (1)
Java Event Handling
3 pages
JavaFX Event Handling
PDF
No ratings yet
JavaFX Event Handling
87 pages
CH 4
PDF
No ratings yet
CH 4
70 pages
Manikandan Development Manual
PDF
No ratings yet
Manikandan Development Manual
77 pages
MODULE-IV Complete Notes Java Events Handling Functions and LayoutManager-1
PDF
No ratings yet
MODULE-IV Complete Notes Java Events Handling Functions and LayoutManager-1
52 pages
Event Handling
PDF
No ratings yet
Event Handling
39 pages
GUI - Event Handling
PDF
No ratings yet
GUI - Event Handling
48 pages
Aad Unit 4
PDF
No ratings yet
Aad Unit 4
31 pages
Binding Data With The AdapterView Class - New
PDF
No ratings yet
Binding Data With The AdapterView Class - New
41 pages
JAVA UNIT-IV Notes
PDF
No ratings yet
JAVA UNIT-IV Notes
19 pages
6.binding Views and Handling Actions
PDF
No ratings yet
6.binding Views and Handling Actions
21 pages
6.binding Views and Handling Actions
PDF
No ratings yet
6.binding Views and Handling Actions
20 pages
WCMC Lesson3
PDF
No ratings yet
WCMC Lesson3
37 pages
PK EventHandling
PDF
No ratings yet
PK EventHandling
20 pages
Event Handling
PDF
No ratings yet
Event Handling
14 pages
COMP4521 - L3 - Event Handler, ImageButton
PDF
No ratings yet
COMP4521 - L3 - Event Handler, ImageButton
22 pages
Ajp CHP 3
PDF
No ratings yet
Ajp CHP 3
31 pages
6.binding Views and Handling Actions
PDF
No ratings yet
6.binding Views and Handling Actions
20 pages
Android Programming: Widget Event Handling: For Live Android Training, Please See Courses
PDF
No ratings yet
Android Programming: Widget Event Handling: For Live Android Training, Please See Courses
27 pages
Input
PDF
No ratings yet
Input
11 pages
Mobile Application Development Presentation: Prepared by Group 5 Members
PDF
No ratings yet
Mobile Application Development Presentation: Prepared by Group 5 Members
21 pages
MAD-Lec 7 Chronometer Listners and Dialogue Box and Menu
PDF
No ratings yet
MAD-Lec 7 Chronometer Listners and Dialogue Box and Menu
22 pages
Event Handling
PDF
No ratings yet
Event Handling
9 pages
PAPB 04A EventHandling
PDF
No ratings yet
PAPB 04A EventHandling
20 pages
Lect6 - Events
PDF
No ratings yet
Lect6 - Events
14 pages
Lecture 5
PDF
No ratings yet
Lecture 5
12 pages
Listeners in Android
PDF
No ratings yet
Listeners in Android
7 pages
Lab01 Android
PDF
No ratings yet
Lab01 Android
10 pages
Unit - III Event Handling in Android Application
PDF
No ratings yet
Unit - III Event Handling in Android Application
14 pages
1.2 Event Handling Introduction
PDF
No ratings yet
1.2 Event Handling Introduction
21 pages
PAPB SI 5 EventHandler
PDF
No ratings yet
PAPB SI 5 EventHandler
22 pages
4 Lists
PDF
No ratings yet
4 Lists
9 pages
GUI Envent Handling
PDF
No ratings yet
GUI Envent Handling
29 pages
2 Designing An App
PDF
No ratings yet
2 Designing An App
4 pages
Splash and Event Handling
PDF
No ratings yet
Splash and Event Handling
4 pages
Android RD
PDF
No ratings yet
Android RD
6 pages
Mobile Application Development: Lecturer M Talha Alam
PDF
No ratings yet
Mobile Application Development: Lecturer M Talha Alam
22 pages
Event Handling
PDF
No ratings yet
Event Handling
4 pages
Vayu Sena
PDF
No ratings yet
Vayu Sena
45 pages
Event Handling
PDF
No ratings yet
Event Handling
74 pages
Event Handling
PDF
No ratings yet
Event Handling
7 pages
4event Listeners
PDF
No ratings yet
4event Listeners
7 pages
GUI Event Handling: Nithya Raman
PDF
No ratings yet
GUI Event Handling: Nithya Raman
38 pages
MC Exp3
PDF
No ratings yet
MC Exp3
2 pages
Event Handling in JAVA
PDF
No ratings yet
Event Handling in JAVA
27 pages
Action and Event Listener
PDF
No ratings yet
Action and Event Listener
6 pages
15 Android Event Handling
PDF
No ratings yet
15 Android Event Handling
9 pages
Module 7: Event Handling in Android Studio: Gordon College
PDF
No ratings yet
Module 7: Event Handling in Android Studio: Gordon College
9 pages