Index Value Issue On The Markers
I want to display these values on markers from the fcmUsers list when user click on marker it will show its own value or data in text view from the fcmUsers list fcmUsers List have
Solution 1:
Firstly, I don't see a reason why you need to store Arraylists off of the Firebase method. I think you should remove them and the i
variable.
If you do need lists, they should only be initialized starting at onDataChange
Secondly, your marker currently only displays the battery.
new MarkerOptions().title(fcmUsers.get(i).Battery.toString())
You can make a String variable of the data you want to show, and replace that.
If you want to store the entire object with the Marker, use tags.
finalModelClassFireBasefcmUser= dataSnapshotChild.getValue(ModelClassFireBase.class);
Markermark= mMap.addMarker(newMarkerOptions()
.title(user.getBattery())
.position(newLatLng(user.getLatitude(), user.getLongitude());
mark.setTag(user);
And down below, get the tag
finalModelClassFireBaseuser= ((ModelClassFireBase) arg0).getTag();
userbattery.setText("user battery:" + user.getBattery());
You cannot use get(i)
in this place because that is not the actual position of that marker
Post a Comment for "Index Value Issue On The Markers"