Daniel Beltrami
Daniel Beltrami

Reputation: 776

Mapview inside a ExpandableListView

I am following this tutorial here and I am trying to change the ImageView for a MapView but I don't know how to do it, because there it explains passing an array of strings for populating the ImageView.

I tried to do something like this:

enter image description here

Upvotes: 0

Views: 90

Answers (1)

Darush
Darush

Reputation: 12031

If you don't know how to use Google MapView follow this tutorial.

If you want to know how to pass the data to your child adapter, instead of array of strings construct an array of latitude-longitude pairs as follows:

List<LatLng> locationList = new ArrayList<>();
locationList.add(new LatLng(55.854049, 13.661331));
locationList.add(new LatLng(56.854049, 14.661331));
.
.
.

In your Child.java class remove int Image and instead add:

private LatLng location;

public int getLatLng() {
    return location;
}

public void setLatLng(LatLng location) {
    this.location = location;
}

And in you SetStandardGroups() method do the needful changes. instead of ch.setImage(Images[j]) add following:

ch.setLatLng(locationList.get(j));

After that if you know how to work with list adapters you should be able to populate the data in you ExpandListAdapter class.

Upvotes: 1

Related Questions