如何将网格视图添加到InfoWindow并检测点击事件?
参见示例:
如果点击了gridview中的其中一个图标,我想将此图标添加到用户点击位置的地图上。
我用来显示弹出菜单的代码:
gMap.setOnMapLongClickListener(new GoogleMap.OnMapLongClickListener() {
@Override
public void onMapLongClick(LatLng location) {
//Create invisible marker and show custom Info Window
MarkerOptions markerInvisible = new MarkerOptions().flat(false).title("Start").alpha(0.00f).infoWindowAnchor(0,1);
markerInvisible.position(location);
Marker invisibleMarker = gMap.addMarker(markerInvisible);
invisibleMarker.showInfoWindow();
contextmenu = true;
}
});
的GridView:
GridView gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new IconboxAdapter(this));
final Context context = this;
gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
Toast.makeText(context, "" + position, Toast.LENGTH_SHORT).show();
}
});