Tuesday 6 January 2015

What is MotionEvent Object when user touches on the screen in Android ?

* When a user touches the touch screen of an Android device, a MotionEvent object is created.

* The MotionEvent contains information about where and when the touch took place,as well as other
details of the touch event.

* The MotionEvent object gets passed to an appropriate method in our application.

* This could be the onTouchEvent() method of a View object.

* Remember that the View class is the parent of quite a few classes in Android including Layouts,
Buttons,Lists,Surfaces,Clocks and more.

* This means we can interact with all of these different types of View objects using touch events.

* When the method is called,it can inspect the MotionEvent object to decide what to do.

* For Example : A MapView could use touch events to move the map sideways to allow the user to
pan the map to other points of interest.

* Or a Virtual Keyboard object could recieve touch events to activate the virtual keys to provide text
input to some other part of the User Interface ( UI ).

No comments:

Post a Comment