0% found this document useful (0 votes)
3 views9 pages

Event Handling

This lecture covers mobile application event handling in Android, focusing on event listeners and handlers. It explains various event listeners such as OnClickListener, OnLongClickListener, and OnTouchListener, detailing how they respond to user interactions. Additionally, it introduces ListView as a component for displaying items in a vertically scrolling list.

Uploaded by

fawad shaikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views9 pages

Event Handling

This lecture covers mobile application event handling in Android, focusing on event listeners and handlers. It explains various event listeners such as OnClickListener, OnLongClickListener, and OnTouchListener, detailing how they respond to user interactions. Additionally, it introduces ListView as a component for displaying items in a vertically scrolling list.

Uploaded by

fawad shaikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

LECTURE – 05

MOBILE
APPLICATION
By: AbuBakar Ubaid
EVENT
HANDLING
By: AbuBakar Ubaid
Android - Event
• Event Listeners − An event listener is an interface in the View
Handling
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

5
OnClickListener()
This is called when the user either clicks or touches or
onClick() focuses upon any widget like button, text, image etc. You
will use onClick() event handler to handle such event.

OnLongClickListener()
This is called when the user either clicks or touches or
onLongClick() focuses upon any widget like button, text, image etc. for one
or more seconds. You will use onLongClick() event handler
to handle such event.

OnFocusChangeListener()
This is called when the widget looses its focus ie. user goes
onFocusChange() away from the view item. You will use onFocusChange()
event handler to handle such event.

OnFocusChangeListener()
This is called when the user is focused on the item and
onKey() presses or releases a hardware key on the device. You will
use onKey() event handler to handle such event.
Event Handler Event Listener & Description

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
onTouch()
event.

OnMenuItemClickListener()
This is called when the user selects a menu item. You
will use onMenuItemClick() event handler to handle
onMenuItemClick() such event.

onCreateContextMenuItemListener()
This is called when the context menu is being
built(as the result of a sustained "long click)
onCreateContextMenu()

6
LIST
VIEW
By: AbuBakar Ubaid
ListView
View
• The ListView
displays a list of
items in a
vertically
scrolling list.

8
LECTURE – 05 “Event
Handling & List View”

THANK YOU

By: AbuBakar Ubaid

You might also like