List of usage examples for android.graphics.drawable LevelListDrawable setLevel
public final boolean setLevel(@IntRange(from = 0, to = 10000) int level)
From source file:com.jesjimher.bicipalma.MapaActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.mapa);/*from w w w.jav a 2s. co m*/ // Activar zoom GoogleMap mapa = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mapfragment)) .getMap(); // mapa.setBuiltInZoomControls(true); mapa.setMyLocationEnabled(true); // Si el mapa no est en Palma o similar, ponerlo en pza espaa CameraPosition c = mapa.getCameraPosition(); Location actual = new Location(""); actual.setLatitude(c.target.latitude); actual.setLongitude(c.target.longitude); Location pe = new Location(""); pe.setLatitude(PZAESPANYA.latitude); pe.setLongitude(PZAESPANYA.longitude); if (actual.distanceTo(pe) >= 5000) mapa.moveCamera(CameraUpdateFactory.newLatLng(PZAESPANYA)); Intent i = getIntent(); // GeoPoint point=null; if (i.hasExtra("estaciones")) { estaciones = i.getExtras().getParcelableArrayList("estaciones"); for (Estacion e : estaciones) { LevelListDrawable d = (LevelListDrawable) getResources().getDrawable(R.drawable.estado_variable); d.setLevel(e.getBicisLibres() + 1); BitmapDrawable bd = (BitmapDrawable) d.getCurrent(); Bitmap b = bd.getBitmap(); Bitmap petit = Bitmap.createScaledBitmap(b, b.getWidth() / 2, b.getHeight() / 2, false); String mensaje = String.format("%s: %d, %s: %d", getResources().getString(R.string.lbicislibres), e.getBicisLibres(), getResources().getString(R.string.lanclajeslibres), e.getAnclajesLibres()); mapa.addMarker(new MarkerOptions() .position(new LatLng(e.getLoc().getLatitude(), e.getLoc().getLongitude())) .title(e.getNombre()).snippet(mensaje).icon(BitmapDescriptorFactory.fromBitmap(petit))); } Double lat = i.getExtras().getDouble("latcentro"); Double lon = i.getExtras().getDouble("longcentro"); mapa.moveCamera(CameraUpdateFactory.zoomTo(16)); mapa.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(lat, lon))); } }