Android 从集群中提取值<;PersonyStuff>;在谷歌地图中

Android 从集群中提取值<;PersonyStuff>;在谷歌地图中,android,google-maps,google-maps-android-api-2,google-maps-api-2,Android,Google Maps,Google Maps Android Api 2,Google Maps Api 2,我正在尝试谷歌在我的地图上提供的集群库。集群正在正常进行,但我正在尝试从集群中提取值。我不知道该怎么做 集群大小为2。我总是得到第一个值 @Override public boolean onClusterClick(Cluster<PersonMyStuff> cluster) { String firstName = cluster.getItems().iterator().next().name; Log.i("MyMaps","Cluster Size"

我正在尝试谷歌在我的地图上提供的集群库。集群正在正常进行,但我正在尝试从集群中提取值。我不知道该怎么做

集群大小为2。我总是得到第一个值

@Override
public boolean onClusterClick(Cluster<PersonMyStuff> cluster) 
{
    String firstName = cluster.getItems().iterator().next().name;

    Log.i("MyMaps","Cluster Size" +cluster.getSize());
    Log.i("MyMaps","First Name" +firstName);

    return true;
}
@覆盖
公共布尔onClusterClick(集群)
{
String firstName=cluster.getItems().iterator().next().name;
Log.i(“MyMaps”,“Cluster Size”+Cluster.getSize());
Log.i(“MyMaps”、“名字”+名字);
返回true;
}
让我知道


谢谢

看起来您只需通过在迭代器上调用一次
next
来访问第一个元素。尝试循环遍历collect中的所有元素

@Override
public boolean onClusterClick(Cluster<PersonMyStuff> cluster) 
{
    Collection<PersonMyStuff> items = cluster.getItems();
    Log.i("MyMaps","Cluster Size" +cluster.getSize());
    for(PersonMyStuff item : items) {
        Log.i("MyMaps","First Name" + item.name);
    }

    return true;
}
@覆盖
公共布尔onClusterClick(集群)
{
集合项=cluster.getItems();
Log.i(“MyMaps”,“Cluster Size”+Cluster.getSize());
for(PersonyStuff项目:项目){
Log.i(“MyMaps”、“名字”+项目名称);
}
返回true;
}