Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
256 views
in Technique[技术] by (71.8m points)

android - My location button event listener

I enabled the my-location layer of the Google Maps Android API v2, which adds the floating button to go to the user's current location. I need a way to detect a click on this button. Is this possible?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Since this question was posted, Google has updated the API. They have added an onMyLocationButtonClick() listener.

To add the listener:

//add location button click listener
map.setOnMyLocationButtonClickListener(new GoogleMap.OnMyLocationButtonClickListener(){
    @Override
    public boolean onMyLocationButtonClick()
    {
        //TODO: Any custom actions
        return false;
    }
});

Returning false will essentially call the super method. Returning true will not.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...