SlideShare ist ein Scribd-Unternehmen logo
1 von 9
Downloaden Sie, um offline zu lesen
MOBILE APPLICATION
DEVELOPMENT
LECTURE – 05
By: AbuBakar Ubaid
EVENT HANDLING
By: AbuBakar Ubaid
Android - Event Handling
• Event Listeners − An event listener is an interface in the View
class that contains a single callback method.These methods
will be called by the Android framework when the View to
which the listener has been registered is triggered by user
interaction with the item in the UI.
• Event Listeners Registration − Event Registration is the
process by which an Event Handler gets registered with an
Event Listener so that the handler is called when the Event
Listener fires the event.
• Event Handlers − When an event happens and we have
registered an event listener for the event, the event listener
calls the Event Handlers, which is the method that actually
handles the event.
3
OnClickListener() and onClick()
//---Button view---
Button btnOpen = (Button)
findViewById(R.id.btnOpen);
btnOpen.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
DisplayToast(“You have clicked the Open button”);
}
});
4
Event Handler Event Listener & Description
onClick()
OnClickListener()
This is called when the user either clicks or touches or
focuses upon any widget like button, text, image etc. You
will use onClick() event handler to handle such event.
onLongClick()
OnLongClickListener()
This is called when the user either clicks or touches or
focuses upon any widget like button, text, image etc. for one
or more seconds. You will use onLongClick() event handler
to handle such event.
onFocusChange()
OnFocusChangeListener()
This is called when the widget looses its focus ie. user goes
away from the view item. You will use onFocusChange()
event handler to handle such event.
onKey()
OnFocusChangeListener()
This is called when the user is focused on the item and
presses or releases a hardware key on the device. You will
use onKey() event handler to handle such event.
5
6
Event Handler Event Listener & Description
onTouch()
OnTouchListener()
This is called when the user presses the key, releases
the key, or any movement gesture on the screen. You
will use onTouch() event handler to handle such
event.
onMenuItemClick()
OnMenuItemClickListener()
This is called when the user selects a menu item. You
will use onMenuItemClick() event handler to handle
such event.
onCreateContextMenu()
onCreateContextMenuItemListener()
This is called when the context menu is being
built(as the result of a sustained "long click)
LIST VIEW
By: AbuBakar Ubaid
ListView View
• The ListView
displays a list of
items in a
vertically
scrolling list.
8
THANK YOU 
LECTURE – 05 “Event Handling & List View”
By: AbuBakar Ubaid

Weitere ähnliche Inhalte

Ähnlich wie Mobile Application Development

Session 12 - Overview of taps, multitouch, and gestures
Session 12 - Overview of taps, multitouch, and gestures Session 12 - Overview of taps, multitouch, and gestures
Session 12 - Overview of taps, multitouch, and gestures
Vu Tran Lam
 
ITE 1122_ Event Handling.pptx
ITE 1122_ Event Handling.pptxITE 1122_ Event Handling.pptx
ITE 1122_ Event Handling.pptx
udithaisur
 

Ähnlich wie Mobile Application Development (20)

Session 12 - Overview of taps, multitouch, and gestures
Session 12 - Overview of taps, multitouch, and gestures Session 12 - Overview of taps, multitouch, and gestures
Session 12 - Overview of taps, multitouch, and gestures
 
Android App development III
Android App development IIIAndroid App development III
Android App development III
 
Java eventhandling
Java eventhandlingJava eventhandling
Java eventhandling
 
Events and Listeners in Android
Events and Listeners in AndroidEvents and Listeners in Android
Events and Listeners in Android
 
B2. activity and intent
B2. activity and intentB2. activity and intent
B2. activity and intent
 
ANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.docANDROID LAB MANUAL.doc
ANDROID LAB MANUAL.doc
 
Unit 6 Java
Unit 6 JavaUnit 6 Java
Unit 6 Java
 
File Handling
File HandlingFile Handling
File Handling
 
Java gui event
Java gui eventJava gui event
Java gui event
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
ITE 1122_ Event Handling.pptx
ITE 1122_ Event Handling.pptxITE 1122_ Event Handling.pptx
ITE 1122_ Event Handling.pptx
 
JAVA PROGRAMMING- GUI Programming with Swing - The Swing Buttons
JAVA PROGRAMMING- GUI Programming with Swing - The Swing ButtonsJAVA PROGRAMMING- GUI Programming with Swing - The Swing Buttons
JAVA PROGRAMMING- GUI Programming with Swing - The Swing Buttons
 
Multimedia lecture ActionScript3
Multimedia lecture ActionScript3Multimedia lecture ActionScript3
Multimedia lecture ActionScript3
 
Java Event Handling
Java Event HandlingJava Event Handling
Java Event Handling
 
Event handling
Event handlingEvent handling
Event handling
 
event-handling.pptx
event-handling.pptxevent-handling.pptx
event-handling.pptx
 
event_handling.ppt
event_handling.pptevent_handling.ppt
event_handling.ppt
 
Chap - 2 - Event Handling.pptx
Chap - 2 - Event Handling.pptxChap - 2 - Event Handling.pptx
Chap - 2 - Event Handling.pptx
 
JAVA GUI PART III
JAVA GUI PART IIIJAVA GUI PART III
JAVA GUI PART III
 
Discuss how each of the following Java components will assist in creat.docx
Discuss how each of the following Java components will assist in creat.docxDiscuss how each of the following Java components will assist in creat.docx
Discuss how each of the following Java components will assist in creat.docx
 

Mehr von Muhammad Sajid

eCommerce App Lecture
eCommerce App LectureeCommerce App Lecture
eCommerce App Lecture
Muhammad Sajid
 
Data Transfer between Activities & Databases
Data Transfer between Activities & DatabasesData Transfer between Activities & Databases
Data Transfer between Activities & Databases
Muhammad Sajid
 

Mehr von Muhammad Sajid (20)

eCommerce App Lecture
eCommerce App LectureeCommerce App Lecture
eCommerce App Lecture
 
Characteristics of enterprise application software
Characteristics of enterprise application softwareCharacteristics of enterprise application software
Characteristics of enterprise application software
 
The Checkout and Order Process
The Checkout and Order ProcessThe Checkout and Order Process
The Checkout and Order Process
 
The Shopping Basket
The Shopping BasketThe Shopping Basket
The Shopping Basket
 
Enhancing the User Experience
Enhancing the User ExperienceEnhancing the User Experience
Enhancing the User Experience
 
Products and Categories
Products and CategoriesProducts and Categories
Products and Categories
 
E-Commerce Applications Development
E-Commerce Applications Development E-Commerce Applications Development
E-Commerce Applications Development
 
E-Commerce Applications Development
E-Commerce Applications Development E-Commerce Applications Development
E-Commerce Applications Development
 
Data Transfer between Activities & Databases
Data Transfer between Activities & DatabasesData Transfer between Activities & Databases
Data Transfer between Activities & Databases
 
Data Transfer between Activities & Databases
Data Transfer between Activities & DatabasesData Transfer between Activities & Databases
Data Transfer between Activities & Databases
 
Data Transfer between Activities & Databases
Data Transfer between Activities & DatabasesData Transfer between Activities & Databases
Data Transfer between Activities & Databases
 
MOBILE APPLICATION DEVELOPMENT
MOBILE APPLICATION DEVELOPMENTMOBILE APPLICATION DEVELOPMENT
MOBILE APPLICATION DEVELOPMENT
 
MOBILE APPLICATION DEVELOPMENT
MOBILE APPLICATION DEVELOPMENTMOBILE APPLICATION DEVELOPMENT
MOBILE APPLICATION DEVELOPMENT
 
MOBILE APPLICATION DEVELOPMENT
MOBILE APPLICATION DEVELOPMENTMOBILE APPLICATION DEVELOPMENT
MOBILE APPLICATION DEVELOPMENT
 
MOBILE APPLICATION DEVELOPMENT
MOBILE APPLICATION DEVELOPMENTMOBILE APPLICATION DEVELOPMENT
MOBILE APPLICATION DEVELOPMENT
 
Your first Android App
Your first Android AppYour first Android App
Your first Android App
 
Group Aided Decision making revised
Group Aided Decision making revisedGroup Aided Decision making revised
Group Aided Decision making revised
 
Pakistan Studies notes
Pakistan Studies notesPakistan Studies notes
Pakistan Studies notes
 
Components of Computing Game
Components of Computing GameComponents of Computing Game
Components of Computing Game
 
Design Elements of Computing Game
Design Elements  of Computing GameDesign Elements  of Computing Game
Design Elements of Computing Game
 

Kürzlich hochgeladen

Kürzlich hochgeladen (20)

Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 

Mobile Application Development

  • 3. Android - Event Handling • Event Listeners − An event listener is an interface in the View class that contains a single callback method.These methods will be called by the Android framework when the View to which the listener has been registered is triggered by user interaction with the item in the UI. • Event Listeners Registration − Event Registration is the process by which an Event Handler gets registered with an Event Listener so that the handler is called when the Event Listener fires the event. • Event Handlers − When an event happens and we have registered an event listener for the event, the event listener calls the Event Handlers, which is the method that actually handles the event. 3
  • 4. OnClickListener() and onClick() //---Button view--- Button btnOpen = (Button) findViewById(R.id.btnOpen); btnOpen.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { DisplayToast(“You have clicked the Open button”); } }); 4
  • 5. Event Handler Event Listener & Description onClick() OnClickListener() This is called when the user either clicks or touches or focuses upon any widget like button, text, image etc. You will use onClick() event handler to handle such event. onLongClick() OnLongClickListener() This is called when the user either clicks or touches or focuses upon any widget like button, text, image etc. for one or more seconds. You will use onLongClick() event handler to handle such event. onFocusChange() OnFocusChangeListener() This is called when the widget looses its focus ie. user goes away from the view item. You will use onFocusChange() event handler to handle such event. onKey() OnFocusChangeListener() This is called when the user is focused on the item and presses or releases a hardware key on the device. You will use onKey() event handler to handle such event. 5
  • 6. 6 Event Handler Event Listener & Description onTouch() OnTouchListener() This is called when the user presses the key, releases the key, or any movement gesture on the screen. You will use onTouch() event handler to handle such event. onMenuItemClick() OnMenuItemClickListener() This is called when the user selects a menu item. You will use onMenuItemClick() event handler to handle such event. onCreateContextMenu() onCreateContextMenuItemListener() This is called when the context menu is being built(as the result of a sustained "long click)
  • 8. ListView View • The ListView displays a list of items in a vertically scrolling list. 8
  • 9. THANK YOU  LECTURE – 05 “Event Handling & List View” By: AbuBakar Ubaid