SlideShare a Scribd company logo
Chapter 13
User Interface Design
By
Dr. Ramkumar Lakshminarayanan
Introduction
Android app's user interface is everything that the user can see and interact with. Android
provides a variety of pre-build UI components such as structured layout objects and UI controls
that allow you to build the graphical user interface for your app. In this unit we discuss about the
standard practice of designing the User Interface. Android also provides other UI modules for
special interfaces such as dialogs, notifications, and menus.
As we discussed in the earlier units all user interface elements in an Android app are built
using View and ViewGroup objects. A View is an object that draws something on the screen that
the user can interact with. A ViewGroup is an object that holds other View (and ViewGroup)
objects in order to define the layout of the interface.
Android provides a collection of both View and ViewGroup subclasses that offer you
common input controls (such as buttons and text fields) and various layout models (such as a
linear or relative layout).
As we discussed in the earlier units about the UI components, you don't have to build all
of your UI using View and ViewGroup objects. Android provides several app components that
offer a standard UI layout for which you simply need to define the content. These UI
components each have a unique set of APIs that are described in their respective documents,
such as Action Bar, Dialogs, and Status Notifications.
Input Controls
Remember, Input controls are the interactive components in your app's user interface.
Android provides a wide variety of controls you can use in your UI, such as buttons, text fields,
seek bars, checkboxes, zoom buttons, toggle buttons, and many more.
Input Events
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.
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.
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.
Included in the event listener interfaces are the following callback methods:
onClick()
From View.OnClickListener. This is called when the user either touches the item (when
in touch mode), or focuses upon the item with the navigation-keys or trackball and presses the
suitable "enter" key or presses down on the trackball.
onLongClick()
From View.OnLongClickListener. This is called when the user either touches and holds
the item (when in touch mode), or focuses upon the item with the navigation-keys or trackball
and presses and holds the suitable "enter" key or presses and holds down on the trackball (for
one second).
onFocusChange()
From View.OnFocusChangeListener. This is called when the user navigates onto or away
from the item, using the navigation-keys or trackball.
onKey()
From View.OnKeyListener. This is called when the user is focused on the item and
presses or releases a hardware key on the device.
onTouch()
From View.OnTouchListener. This is called when the user performs an action qualified
as a touch event, including a press, a release, or any movement gesture on the screen (within the
bounds of the item).
onCreateContextMenu()
From View.OnCreateContextMenuListener. This is called when a Context Menu is being
built (as the result of a sustained "long click"). These methods are the sole inhabitants of their
respective interface. To define one of these methods and handle your events, implement the
nested interface in your Activity or define it as an anonymous class. Then, pass an instance of
your implementation to the respective View.set...Listener() method. (E.g., call
setOnClickListener() and pass it your implementation of the OnClickListener.)

More Related Content

PPTX
Android UI
PPT
android layouts
PPT
Londroid Android Home Screen Widgets
PPT
Multiple Activity and Navigation Primer
PDF
04 user interfaces
PPT
View groups containers
PPT
Day 3: Getting Active Through Activities
PPT
Android User Interface: Basic Form Widgets
Android UI
android layouts
Londroid Android Home Screen Widgets
Multiple Activity and Navigation Primer
04 user interfaces
View groups containers
Day 3: Getting Active Through Activities
Android User Interface: Basic Form Widgets

What's hot (20)

PPTX
Android Workshop: Day 1 Part 3
PPTX
Day 15: Working in Background
PPTX
Android MapView and MapActivity
DOCX
Android views and layouts-chapter4
PPTX
Android application-component
PDF
Android session 2
PDF
Marakana Android User Interface
PDF
Training android
PDF
Android session 3
PDF
Android session 1
PPT
Day 4: Android: Getting Active through Activities
PPTX
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
PPT
Day 4: Android: UI Widgets
PPTX
Android components
PPTX
PPTX
Android apps development
PDF
Android UI Fundamentals part 1
PDF
Android Lesson 2
PPTX
Android Training in Chandigarh
PPTX
Android Fundamental
Android Workshop: Day 1 Part 3
Day 15: Working in Background
Android MapView and MapActivity
Android views and layouts-chapter4
Android application-component
Android session 2
Marakana Android User Interface
Training android
Android session 3
Android session 1
Day 4: Android: Getting Active through Activities
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Day 4: Android: UI Widgets
Android components
Android apps development
Android UI Fundamentals part 1
Android Lesson 2
Android Training in Chandigarh
Android Fundamental
Ad

Similar to Android user interface design-chapter13 (20)

DOC
ANDROID LAB MANUAL.doc
PDF
Mobile Application Development
PPTX
Android App development III
PPTX
Android Mobile application development - Event Handling (1).pptx
PPTX
Notes Unit3.pptx
DOCX
Android Tutorial For Beginners Part-1
PPTX
Android application componenets for android app development
PPT
Android Presentation for fundamental.ppt
PPTX
creating User interface in mobile and app dev
PPTX
Unit 3 Mobile Application development, NEP Syllabus
PPTX
Get an Android tutorial for beginners
PPT
"Android" mobilių programėlių kūrimo įvadas #2
DOC
Final Essay
PDF
Introduction to Android Development
PDF
Android development - Activities, Views & Intents
PPT
Day 3: Getting Active Through Activities
PPTX
Androd Listeners
PPTX
Android Development Company in Lucknow
PPTX
Android Development Company in Lucknow
DOCX
COIT20270 Application Development for Mobile PlatformsWeek 4.docx
ANDROID LAB MANUAL.doc
Mobile Application Development
Android App development III
Android Mobile application development - Event Handling (1).pptx
Notes Unit3.pptx
Android Tutorial For Beginners Part-1
Android application componenets for android app development
Android Presentation for fundamental.ppt
creating User interface in mobile and app dev
Unit 3 Mobile Application development, NEP Syllabus
Get an Android tutorial for beginners
"Android" mobilių programėlių kūrimo įvadas #2
Final Essay
Introduction to Android Development
Android development - Activities, Views & Intents
Day 3: Getting Active Through Activities
Androd Listeners
Android Development Company in Lucknow
Android Development Company in Lucknow
COIT20270 Application Development for Mobile PlatformsWeek 4.docx
Ad

More from Dr. Ramkumar Lakshminarayanan (20)

PPT
IT security awareness
PPT
Basics of IT security
PDF
IT Security Awareness Posters
PPT
Normalisation revision
PPTX
Windows mobile programming
PPTX
Concurrency control
PPT
Web technology today
PDF
Phonegap for Android
PDF
Create and Sell Android App (in tamil)
PDF
Android app - Creating Live Wallpaper (tamil)
PDF
Android Tips (Tamil)
PDF
Android Animation (in tamil)
PDF
Creating List in Android App (in tamil)
PDF
Single Touch event view in Android (in tamil)
PDF
Android Application using seekbar (in tamil)
PDF
Rating Bar in Android Example
PDF
Creating Image Gallery - Android app (in tamil)
PDF
Create Android App using web view (in tamil)
PDF
Hardware Interface in Android (in tamil)
IT security awareness
Basics of IT security
IT Security Awareness Posters
Normalisation revision
Windows mobile programming
Concurrency control
Web technology today
Phonegap for Android
Create and Sell Android App (in tamil)
Android app - Creating Live Wallpaper (tamil)
Android Tips (Tamil)
Android Animation (in tamil)
Creating List in Android App (in tamil)
Single Touch event view in Android (in tamil)
Android Application using seekbar (in tamil)
Rating Bar in Android Example
Creating Image Gallery - Android app (in tamil)
Create Android App using web view (in tamil)
Hardware Interface in Android (in tamil)

Recently uploaded (6)

PPTX
ASMS Telecommunication company Profile
PDF
heheheueueyeyeyegehehehhehshMedia-Literacy.pdf
DOC
Camb毕业证学历认证,格罗斯泰斯特主教大学毕业证仿冒文凭毕业证
PDF
Lesson 13- HEREDITY _ pedSAWEREGFVCXZDSASEWFigree.pdf
PDF
6-UseCfgfhgfhgfhgfhgfhfhhaseActivity.pdf
DOC
证书学历UoA毕业证,澳大利亚中汇学院毕业证国外大学毕业证
ASMS Telecommunication company Profile
heheheueueyeyeyegehehehhehshMedia-Literacy.pdf
Camb毕业证学历认证,格罗斯泰斯特主教大学毕业证仿冒文凭毕业证
Lesson 13- HEREDITY _ pedSAWEREGFVCXZDSASEWFigree.pdf
6-UseCfgfhgfhgfhgfhgfhfhhaseActivity.pdf
证书学历UoA毕业证,澳大利亚中汇学院毕业证国外大学毕业证

Android user interface design-chapter13

  • 1. Chapter 13 User Interface Design By Dr. Ramkumar Lakshminarayanan Introduction Android app's user interface is everything that the user can see and interact with. Android provides a variety of pre-build UI components such as structured layout objects and UI controls that allow you to build the graphical user interface for your app. In this unit we discuss about the standard practice of designing the User Interface. Android also provides other UI modules for special interfaces such as dialogs, notifications, and menus. As we discussed in the earlier units all user interface elements in an Android app are built using View and ViewGroup objects. A View is an object that draws something on the screen that the user can interact with. A ViewGroup is an object that holds other View (and ViewGroup) objects in order to define the layout of the interface. Android provides a collection of both View and ViewGroup subclasses that offer you common input controls (such as buttons and text fields) and various layout models (such as a linear or relative layout). As we discussed in the earlier units about the UI components, you don't have to build all of your UI using View and ViewGroup objects. Android provides several app components that offer a standard UI layout for which you simply need to define the content. These UI components each have a unique set of APIs that are described in their respective documents, such as Action Bar, Dialogs, and Status Notifications. Input Controls Remember, Input controls are the interactive components in your app's user interface. Android provides a wide variety of controls you can use in your UI, such as buttons, text fields, seek bars, checkboxes, zoom buttons, toggle buttons, and many more. Input Events 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.
  • 2. 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. 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. Included in the event listener interfaces are the following callback methods: onClick() From View.OnClickListener. This is called when the user either touches the item (when in touch mode), or focuses upon the item with the navigation-keys or trackball and presses the suitable "enter" key or presses down on the trackball. onLongClick() From View.OnLongClickListener. This is called when the user either touches and holds the item (when in touch mode), or focuses upon the item with the navigation-keys or trackball and presses and holds the suitable "enter" key or presses and holds down on the trackball (for one second). onFocusChange() From View.OnFocusChangeListener. This is called when the user navigates onto or away from the item, using the navigation-keys or trackball. onKey()
  • 3. From View.OnKeyListener. This is called when the user is focused on the item and presses or releases a hardware key on the device. onTouch() From View.OnTouchListener. This is called when the user performs an action qualified as a touch event, including a press, a release, or any movement gesture on the screen (within the bounds of the item). onCreateContextMenu() From View.OnCreateContextMenuListener. This is called when a Context Menu is being built (as the result of a sustained "long click"). These methods are the sole inhabitants of their respective interface. To define one of these methods and handle your events, implement the nested interface in your Activity or define it as an anonymous class. Then, pass an instance of your implementation to the respective View.set...Listener() method. (E.g., call setOnClickListener() and pass it your implementation of the OnClickListener.)