Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I make a unique variable name in android?
    primarykey
    data
    text
    <p>I want to display more points on a map. I want to do that with a "for". My problem is that only the last point is displayed, because variables: point and overlayItem are overwritten each time. How can I make a unique name for this variables?</p> <pre><code> List&lt;Statia&gt; arrStatia = datasourceStatia.getAllStatias(); for (Statia s : arrStatia) { String[] arrCoordonate = s.getCoord().split(","); GeoPoint point = new GeoPoint((int)(Double.parseDouble(arrCoordonate[1])),(int)(Double.parseDouble(arrCoordonate[0]))); OverlayItem overlayItem = new OverlayItem(point, Double.parseDouble(arrCoordonate[1]) + "", Double.parseDouble(arrCoordonate[0]) +""); itemizedOverlay.addOverlay(overlayItem); mapOverlays.add(itemizedOverlay); mapView.postInvalidate(); Log.v("xxx", s.getCoord()); } public class Statia { private long id; private String statia; private long idruta; private String coord; private String program; public long getId() { return id; } public void setId(long id) { this.id = id; } public long getIdRuta() { return idruta; } public void setIdRuta(long idruta) { this.idruta = idruta; } public String getStatia() { return statia; } public void setStatia(String statia) { this.statia = statia; } public void setCoord(String coord) { this.coord = coord; } public String getCoord() { return coord; } public void setProgram(String program) { this.program = program; } public String getProgram() { return program; } // Will be used by the ArrayAdapter in the ListView @Override public String toString() { return statia; } } public List&lt;Statia&gt; getAllStatias() { List&lt;Statia&gt; statias = new ArrayList&lt;Statia&gt;(); Cursor cursor = database.query(DatabaseHelper.statiiTable, allColumns, null, null, null, null, null); cursor.moveToFirst(); while (!cursor.isAfterLast()) { Statia statia = cursorToStatia(cursor); statias.add(statia); cursor.moveToNext(); } // Make sure to close the cursor cursor.close(); return statias; } private Statia cursorToStatia(Cursor cursor) { Statia statia = new Statia(); statia.setId(cursor.getLong(0)); statia.setStatia(cursor.getString(1)); statia.setIdRuta(cursor.getInt(2)); statia.setCoord(cursor.getString(3)); statia.setProgram(cursor.getString(4)); return statia; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload