0

I have a variable that I need to use in an inner class but the only way java letme uset it it´s declaring it as final, but I need to use it without it, letme paste you the code:

  for (Taxi taxi : taxis) {
            final Ubicaciones u= taxi.getUbicacionActual();
            LatLng ubicacion= new LatLng(Double.parseDouble(u.getLatitud()), Double.parseDouble(u.getLongitud()));


            map.moveCamera(CameraUpdateFactory.newLatLngZoom(ubicacion,15));

            MarkerOptions punto= new MarkerOptions().position(ubicacion);
            map.addMarker(punto);

            map.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
                @Override
                public View getInfoWindow(Marker marker) {
                    return null;
                }

                @Override
                public View getInfoContents(Marker marker) {
                    View v = getLayoutInflater().inflate(R.layout.info_title,null);


                    TextView info1= (TextView) v.findViewById(R.id.info1);
                    TextView info2= (TextView) v.findViewById(R.id.info2);
                    TextView info3= (TextView) v.findViewById(R.id.info3);
                    info1.setText("Fecha: "+u.getFecha());
                    info3.setText("Longitud: "+u.getLongitud().toString());


                    return v;
                }
            });

The variable it´s "Ubicaciones u", as you can see in the code it´´t declared as final, could someone tell me how can I use it without that, best regards.

1 Answers1

0

Declare the required variable as global it will solve your problem. But I would recommend you to go through answers here.

Community
  • 1
  • 1