comment compter le nombre de clics sur le marqueur de carte google dans android
Shareque
Comment obtenir le nombre de clics/tapotements sur un marqueur dans google maps.
@Override
public boolean onMarkerClick(Marker point) {
Toast.makeText(MapsActivity.this, point.getTitle(), Toast.LENGTH_SHORT).show();
Integer clickCount = (Integer) point.getTag();
// Check if a click count was set, then display the click count.
if (clickCount != null) {
clickCount = clickCount + 1;
point.setTag(clickCount);
Toast.makeText(this, point.getTitle() + " has been clicked " + clickCount + " times.", Toast.LENGTH_SHORT).show();
}
return true;
}
antonio
Vous l'avez presque fait fonctionner:
@Override
public boolean onMarkerClick(Marker point) {
Toast.makeText(MapsActivity.this, point.getTitle(), Toast.LENGTH_SHORT).show();
Integer clickCount = (Integer) point.getTag();
if (clickCount == null) {
clickCount = 0;
}
clickCount = clickCount + 1;
point.setTag(clickCount);
Toast.makeText(this, point.getTitle() + " has been clicked " + clickCount + " times.", Toast.LENGTH_SHORT).show();
return true;
}