Deck 7: Touches and Swipes

Full screen (f)
exit full mode
Question
Touching the screen can be detected on Android devices.
Use Space or
up arrow
down arrow
to flip the card.
Question
To handle touch events, one of the things we must do is define a class that implements View.OnTouchListener and overrides its ____________ method.
Question
The public field of the ViewGroup.MarginLayoutParams class defining a right margin is ____________.
Question
The onTouch method on View.OnTouchListener has this API:
boolean onTouch( View v, MotionEvent event )
The second parameter, v, represents the current touch event.
Question
The rgb ____________ method of the Color class can be used to create a Color.
Question
It is possible that two Views overlap, in which case one View is stacked above the other View.
Question
The onSingleTapUp method of the GestureDetector.OnGestureListener interface is called on a(n) ____________ action when a touch occurs.
Question
It is possible for a device to detect taps.
Question
Which method of the GestureDetector class should we call from the onTouchEvent method of the Activity class to dispatch a touch event to the appropriate method of the listener interfaces?

A) onTouchEvent
B) onDispatch
C) dispatch
D) callListener
Question
It is possible to adjust the font size of a TextView depending on the text contained inside the TextView.
Question
What does the getRawX method of MouseEvent return?

A) The x coordinate of the touch within the screen
B) The x coordinate of the touch within the View where the touch happened
C) The x coordinate of the top of the screen
D) The x coordinate of the top of the View where the touch happened
Question
What does the getAction method of MouseEvent return?

A) A double
B) A float
C) An int, the x coordinate of the touch within the screen
D) An int, representing the type of action that occurred
Question
We want to be able to compare the starting coordinate of a touch with the ending coordinate of a touch. How can we do it?

A) We cannot compare those coordinates.
B) We can compare them inside the onTouch method when it is called; nothing additional needed.
C) Store the ending coordinate in an instance variable and compare it to the starting coordinate of the touch inside the onTouch method.
D) Store the starting coordinate in an instance variable and compare it to the ending coordinate of the touch inside the onTouch method.
Question
The getX method of MouseEvent returns:

A) the x coordinate of the touch within the screen.
B) the x coordinate of the touch within the View where the touch occurred.
C) the x coordinate of the top of the screen.
D) the x coordinate of the top of the View where the touch occurred.
Question
We can enable the user to move a TextView.
Question
One of the things we must do to handle touch events is create an object of a class that __________________ View.OnTouchListener.
Question
One of the things we must do to handle touch events is register an object of a class that implements View.OnTouchListener on one or more __________________.
Question
The public field of the ViewGroup.MarginLayoutParams class defining a bottom margin is __________________.
Question
The public field of the ViewGroup.MarginLayoutParams class defining a top margin is __________________.
Question
The __________________ interface notifies us of double taps or confirmed single taps.
Question
The onDown method of the GestureDetector.OnGestureListener interface is called on a(n) __________________ action when a touch occurs.
Question
If a TextView has not been displayed yet, it is possible to retrieve measurements about its width and height using the __________________ method.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/22
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 7: Touches and Swipes
1
Touching the screen can be detected on Android devices.
True
2
To handle touch events, one of the things we must do is define a class that implements View.OnTouchListener and overrides its ____________ method.
onTouch
3
The public field of the ViewGroup.MarginLayoutParams class defining a right margin is ____________.
rightMargin
4
The onTouch method on View.OnTouchListener has this API:
boolean onTouch( View v, MotionEvent event )
The second parameter, v, represents the current touch event.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
5
The rgb ____________ method of the Color class can be used to create a Color.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
6
It is possible that two Views overlap, in which case one View is stacked above the other View.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
7
The onSingleTapUp method of the GestureDetector.OnGestureListener interface is called on a(n) ____________ action when a touch occurs.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
8
It is possible for a device to detect taps.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
9
Which method of the GestureDetector class should we call from the onTouchEvent method of the Activity class to dispatch a touch event to the appropriate method of the listener interfaces?

A) onTouchEvent
B) onDispatch
C) dispatch
D) callListener
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
10
It is possible to adjust the font size of a TextView depending on the text contained inside the TextView.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
11
What does the getRawX method of MouseEvent return?

A) The x coordinate of the touch within the screen
B) The x coordinate of the touch within the View where the touch happened
C) The x coordinate of the top of the screen
D) The x coordinate of the top of the View where the touch happened
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
12
What does the getAction method of MouseEvent return?

A) A double
B) A float
C) An int, the x coordinate of the touch within the screen
D) An int, representing the type of action that occurred
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
13
We want to be able to compare the starting coordinate of a touch with the ending coordinate of a touch. How can we do it?

A) We cannot compare those coordinates.
B) We can compare them inside the onTouch method when it is called; nothing additional needed.
C) Store the ending coordinate in an instance variable and compare it to the starting coordinate of the touch inside the onTouch method.
D) Store the starting coordinate in an instance variable and compare it to the ending coordinate of the touch inside the onTouch method.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
14
The getX method of MouseEvent returns:

A) the x coordinate of the touch within the screen.
B) the x coordinate of the touch within the View where the touch occurred.
C) the x coordinate of the top of the screen.
D) the x coordinate of the top of the View where the touch occurred.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
15
We can enable the user to move a TextView.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
16
One of the things we must do to handle touch events is create an object of a class that __________________ View.OnTouchListener.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
17
One of the things we must do to handle touch events is register an object of a class that implements View.OnTouchListener on one or more __________________.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
18
The public field of the ViewGroup.MarginLayoutParams class defining a bottom margin is __________________.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
19
The public field of the ViewGroup.MarginLayoutParams class defining a top margin is __________________.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
20
The __________________ interface notifies us of double taps or confirmed single taps.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
21
The onDown method of the GestureDetector.OnGestureListener interface is called on a(n) __________________ action when a touch occurs.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
22
If a TextView has not been displayed yet, it is possible to retrieve measurements about its width and height using the __________________ method.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 22 flashcards in this deck.