Книга: Beginning Android
Handling Screen Taps
Handling Screen Taps
An Overlay
subclass can also implement onTap()
, to be notified when the user taps on the map, so the overlay can adjust what it draws. For example, in full-size Google Maps, clicking on a push-pin pops up a bubble with information about the business at that pin’s location. With onTap()
, you can do much the same in Android.
The onTap()
method for ItemizedOverlay
receives the index of the OverlayItem
that was clicked. It is up to you to do something worthwhile with this event.
In the case of SitesOverlay
, as previously shown, onTap()
looks like this:
@Override
protected boolean onTap(int i) {
Toast.makeText(NooYawk.this,
items.get(i).getSnippet(), Toast.LENGTH_SHORT).show();
return(true);
}
Here, we just toss up a short Toast
with the “snippet” from the OverlayItem
, returning true to indicate we handled the tap.
- DirectX Tutorial 4: Full Screen and Depth Buffers
- CHAPTER 21 Handling Electronic Mail
- Capturing Screen Images
- Handling HTML Forms
- 5.3.1 mikroC IDE Screen
- PROJECT 7.1 — Read CID Register and Display on a PC Screen
- Handling Name Server Lookups
- Handling Control Messages
- 11.5 A Model for Implementing the Soft-Timer Handling Facility
- Chapter 12 Exception Handling
- Handling Events
- Handling Exceptions