ClusterManager setTextColor doesn't work as expected

Viewed 24

I am working on this code. I can't figure out what could be wrong, because the text color doesn't change when I use the ClusterManager. Even if I use the first example and just add the line ClusterManager<ClusterItem> mClusterManager = new ClusterManager<>(this, mMap) the text color change also stops working. I will appreciate any help on this.

With this code it works fine:

mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
    public View getInfoWindow(Marker arg0) {
        return null;
    }
    public View getInfoContents(Marker arg0) {
        View infoMarcador = getLayoutInflater().inflate(R.layout.custom_infowindow, null);
        TextView titulo = ((TextView)infoMarcador.findViewById(R.id.infoWinEtiquetaTitulo));
        titulo.setText(arg0.getTitle());
        titulo.setTextColor(ContextCompat.getColor(MapsActivity.this, R.color.red));
        TextView subTitulo = ((TextView)infoMarcador.findViewById(R.id.infoWinEtiquetaSnippet));
        subTitulo.setText(arg0.getSnippet());
        subTitulo.setTextColor(ContextCompat.getColor(MapsActivity.this, R.color.red));
        return infoMarcador;
    }
});

With this code the color of the text does not change, it is always black:

ClusterManager<ClusterItem> mClusterManager = new ClusterManager<>(this, mMap);
MarkerManager.Collection markerCollection = mClusterManager.getMarkerCollection();
markerCollection.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
    @Override
    public View getInfoWindow(@NonNull Marker marker) {
        return null;
    }
    @Override
    public View getInfoContents(@NonNull Marker marker) {
        View infoMarcador = getLayoutInflater().inflate(R.layout.custom_infowindow, null);
        TextView titulo = ((TextView)infoMarcador.findViewById(R.id.infoWinEtiquetaTitulo));
        titulo.setText(marker.getTitle());
        titulo.setTextColor(getColor(R.color.red));
        TextView subTitulo = ((TextView)infoMarcador.findViewById(R.id.infoWinEtiquetaSnippet));
        subTitulo.setText(marker.getSnippet());
        subTitulo.setTextColor(getColor(R.color.red));
        return infoMarcador;
    }
});
0 Answers
Related