SlideShare a Scribd company logo
Android
Touch
Android Training
By Khaled Anaqwa
Android touch basics
 The Android standard View class support
touch events.
 You can react to touch events in your
custom views and your activities.
 Android supports multiple pointers, e.g.
fingers which are interacting with the
screen.
 The base class for touch support is the
MotionEvent class which is passed to
Views via the onTouchEvent() method.
 To react to touch events you override the
onTouchEvent() method.
Single touch
 If single input is used you can use the
getX() and getY() methods to get the
current position of the first finger.
 Via the getAction() method you receive
the action which was performed
The MotionEvent class provides the following
constants to determine the action which was
performed.
Demo
 Using One Touch
 Create custom View
 Draw in it
 Track touches points
 Draw lines while move
Task
 Draw dot’s and connects these dot’s on
screen
Gestures
 Android provides special types of touch
screen events such as pinch , double tap,
scrolls , long presses and flinch. These are
all known as gestures.
 Android provides GestureDetector class
to receive motion events and tell us that
these events correspond to gestures or
not.
Using
 you need to create an object of
GestureDetector and then extend
another class with
GestureDetector.SimpleOnGestureListener
to act as a listener.
Gestures Type
 Touch
 Long press
 Swipe or drag
 Long press drag
 Double touch (Tap)
 Pinch open / close
Where I can use onTouch
Listener
 onTouchEvent (Activity Override)
 onTouchEvent (CustomView Override)
 onTouch(view.setOnTouchListener)
Demo
 Use GestureDetector.
SimpleOnGestureListener
Task
 Create Listview and implement Swipe to
delete

More Related Content

PPTX
Android training (android style)
PPTX
Android Training (Services)
PPTX
Android Training (Broadcast Receiver)
PPTX
Android Training (android fundamental)
PPTX
Android Training (Notifications)
PPTX
Android Training (ScrollView , Horizontal ScrollView WebView)
PPT
Chapter 5 ms access-1
PPTX
Android Transition
Android training (android style)
Android Training (Services)
Android Training (Broadcast Receiver)
Android Training (android fundamental)
Android Training (Notifications)
Android Training (ScrollView , Horizontal ScrollView WebView)
Chapter 5 ms access-1
Android Transition

Viewers also liked (20)

PPTX
Android Training (Animation)
PPT
MS Access Training
PPT
Uses of MS Access in Business
PPTX
Content provider in_android
PPTX
Wi-Fi Direct
PPTX
Android Training (Storing & Shared Preferences)
PPTX
Android Training (Content Provider)
PPT
Wifi direct p2p app
PPT
Android Sensor System
PPT
Chapter 3 storage media and devices
PPT
Chapter 8 system analysis and design
PDF
Introduction to Wi-Fi Direct
PPT
Smartphone sensor and gesture
PPT
C hapter 1 types-and_components_of_computer_system[1][1]
PPTX
Android Sensor
ODP
Android sensors
PPTX
Android - Broadcast Receiver
PPTX
Android - Sensor Manager
PPTX
PPT
Training MS Access 2007
Android Training (Animation)
MS Access Training
Uses of MS Access in Business
Content provider in_android
Wi-Fi Direct
Android Training (Storing & Shared Preferences)
Android Training (Content Provider)
Wifi direct p2p app
Android Sensor System
Chapter 3 storage media and devices
Chapter 8 system analysis and design
Introduction to Wi-Fi Direct
Smartphone sensor and gesture
C hapter 1 types-and_components_of_computer_system[1][1]
Android Sensor
Android sensors
Android - Broadcast Receiver
Android - Sensor Manager
Training MS Access 2007
Ad

Similar to Android Training (Touch) (20)

PDF
Session 12 - Overview of taps, multitouch, and gestures
DOCX
Android user interface design-chapter13
PPT
Multi Touch And Gesture Event Interface And Types
PPTX
Advance ui development and design
PPTX
Androd Listeners
PDF
Mobile Application Development
PDF
Multi Touch presentation
DOC
ANDROID LAB MANUAL.doc
PPT
Flash Lite & Touch: build an iPhone-like dynamic list
PPTX
Interactive Screen
PPTX
Mie presentation
PPTX
Project presentation -chady abidi
PPTX
Mobile Application Development class 005
PPTX
Fast multi touch enabled web sites
PPTX
Tips for building fast multi touch enabled web sites
PDF
Scratching the Surface with JavaFX
PDF
Ajp notes-chapter-03
PPTX
Developing accessible android applications
PDF
Automate Mobile Gestures in Appium_ A Detailed Guide for Developers.pdf
Session 12 - Overview of taps, multitouch, and gestures
Android user interface design-chapter13
Multi Touch And Gesture Event Interface And Types
Advance ui development and design
Androd Listeners
Mobile Application Development
Multi Touch presentation
ANDROID LAB MANUAL.doc
Flash Lite & Touch: build an iPhone-like dynamic list
Interactive Screen
Mie presentation
Project presentation -chady abidi
Mobile Application Development class 005
Fast multi touch enabled web sites
Tips for building fast multi touch enabled web sites
Scratching the Surface with JavaFX
Ajp notes-chapter-03
Developing accessible android applications
Automate Mobile Gestures in Appium_ A Detailed Guide for Developers.pdf
Ad

More from Khaled Anaqwa (7)

PPTX
Android Training (Storing data using SQLite)
PPTX
Android Training (Sensors)
PPTX
Android Training (Media)
PPTX
Android Training (AdapterView & Adapter)
PPTX
Android Training (Android UI)
PPTX
Android Training (Intro)
PPTX
Android Training (Java Review)
Android Training (Storing data using SQLite)
Android Training (Sensors)
Android Training (Media)
Android Training (AdapterView & Adapter)
Android Training (Android UI)
Android Training (Intro)
Android Training (Java Review)

Recently uploaded (20)

PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
KodekX | Application Modernization Development
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Unlocking AI with Model Context Protocol (MCP)
PPT
Teaching material agriculture food technology
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Encapsulation theory and applications.pdf
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Electronic commerce courselecture one. Pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Big Data Technologies - Introduction.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Review of recent advances in non-invasive hemoglobin estimation
KodekX | Application Modernization Development
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Unlocking AI with Model Context Protocol (MCP)
Teaching material agriculture food technology
The AUB Centre for AI in Media Proposal.docx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Empathic Computing: Creating Shared Understanding
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Advanced methodologies resolving dimensionality complications for autism neur...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Reach Out and Touch Someone: Haptics and Empathic Computing
Encapsulation theory and applications.pdf
sap open course for s4hana steps from ECC to s4
Electronic commerce courselecture one. Pdf

Android Training (Touch)

  • 2. Android touch basics  The Android standard View class support touch events.  You can react to touch events in your custom views and your activities.  Android supports multiple pointers, e.g. fingers which are interacting with the screen.
  • 3.  The base class for touch support is the MotionEvent class which is passed to Views via the onTouchEvent() method.  To react to touch events you override the onTouchEvent() method.
  • 4. Single touch  If single input is used you can use the getX() and getY() methods to get the current position of the first finger.  Via the getAction() method you receive the action which was performed
  • 5. The MotionEvent class provides the following constants to determine the action which was performed.
  • 6. Demo  Using One Touch  Create custom View  Draw in it  Track touches points  Draw lines while move
  • 7. Task  Draw dot’s and connects these dot’s on screen
  • 8. Gestures  Android provides special types of touch screen events such as pinch , double tap, scrolls , long presses and flinch. These are all known as gestures.  Android provides GestureDetector class to receive motion events and tell us that these events correspond to gestures or not.
  • 9. Using  you need to create an object of GestureDetector and then extend another class with GestureDetector.SimpleOnGestureListener to act as a listener.
  • 10. Gestures Type  Touch  Long press  Swipe or drag  Long press drag  Double touch (Tap)  Pinch open / close
  • 11. Where I can use onTouch Listener  onTouchEvent (Activity Override)  onTouchEvent (CustomView Override)  onTouch(view.setOnTouchListener)
  • 13. Task  Create Listview and implement Swipe to delete