custom info window showing duplicate data from json android studio

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



custom info window showing duplicate data from json android studio



I'm really new to android programming.



Can i ask a question, why my data is all same. I'm getting data from json and put it in custom info window, why it's all duplicate but the markers are not.
I'm sorry i can't send pictures because my first time here asking questions



This is my Adapter class



Adapter Class


public class MarkerInfoWindowAdapter implements GoogleMap.InfoWindowAdapter
private Context context;
private TextView tvnama, tvalamat, tvkursi, tvmeja, tvstop, tvlain, tvket;
public static String stonama, stoalamat, kursisto, mejasto, stopkontaksto, lainlainsto, keterangansto, id;
public MarkerInfoWindowAdapter(Context context)
this.context = context.getApplicationContext();


@Override
public View getInfoWindow(Marker marker)
return null;

@Override
public View getInfoContents(Marker marker)
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.map_marker_info_window, null);
tvnama = (TextView) v.findViewById(R.id.tv_namasto);
tvalamat = (TextView) v.findViewById(R.id.tv_alamatsto);
tvkursi = (TextView) v.findViewById(R.id.tv_kursisto);
tvmeja = (TextView) v.findViewById(R.id.tv_mejasto);
tvstop = (TextView) v.findViewById(R.id.tv_stopkontaksto);
tvlain = (TextView) v.findViewById(R.id.tv_lainlainsto);
tvket = (TextView) v.findViewById(R.id.tv_keterangansto);
tvnama.setText("Nama STO: "+stonama);
tvalamat.setText("Alamat STO: "+stoalamat);
tvkursi.setText("Fasilitas Kursi: "+kursisto);
tvmeja.setText("Fasilitas Meja: "+mejasto);
tvstop.setText("Fasilitas Stop Kontak: "+stopkontaksto);
tvlain.setText("Fasilitas Lain Lain: "+lainlainsto);
tvket.setText("Keterangan: "+keterangansto);
return v;




MapsActivity``


public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {

private GoogleMap mMap;
private String nama_sto, alamat_sto, kursi, meja, stop, lain, keterangan, id;
int numData;
LatLng latLng;
Boolean markerD;
private Double latitude, longitude;

private void getLokasi() {
String url = "http://huracan97.site/api/GetSTO.php";
JsonArrayRequest request = new JsonArrayRequest
(Request.Method.GET, url, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response)
numData = response.length();
Log.d("DEBUG_", "Parse JSON");
latLng = new LatLng[numData];
markerD = new Boolean[numData];
id = new String[numData];
nama_sto = new String[numData];
alamat_sto = new String[numData];
kursi = new String[numData];
meja = new String[numData];
stop = new String[numData];
lain = new String[numData];
keterangan = new String[numData];
latitude = new Double[numData];
longitude = new Double[numData];

for (int i = 0; i < numData; i++)
try
JSONObject data = response.getJSONObject(i);
id[i] = data.getString("id_sto");
latLng[i] = new LatLng(data.getDouble("latitude"),
data.getDouble("longitude"));
nama_sto[i] = data.getString("nama_sto");
alamat_sto[i] = data.getString("alamat_sto");
kursi[i] = data.getString("fasilitas_kursi");
meja[i] = data.getString("fasilitas_meja");
stop[i] = data.getString("fasilitas_stopkontak");
lain[i] = data.getString("fasilitas_lainlain");
keterangan[i] = data.getString("keterangan");
latitude[i] = data.getDouble("latitude");
longitude[i] = data.getDouble("longitude");
MarkerInfoWindowAdapter.stonama = nama_sto[i];
MarkerInfoWindowAdapter.stoalamat = alamat_sto[i];
MarkerInfoWindowAdapter.kursisto = kursi[i];
MarkerInfoWindowAdapter.mejasto = meja[i];
MarkerInfoWindowAdapter.stopkontaksto = stop[i];
MarkerInfoWindowAdapter.lainlainsto = lain[i];
MarkerInfoWindowAdapter.keterangansto = keterangan[i];
markerD[i] = false;
mMap.addMarker(new MarkerOptions()
.position(latLng[i])

);

catch (JSONException je)

mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng[i], 15.5f));













By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS