当我点击第一个片段中的特定数据(位置)时,我想导航到第二个片段并在地图和数据上显示一个标记
When i click on particular data(location) in the first fragment i want to navigate to the second fragment and show a marker on the map and data
我有两个使用 View Pager
实现的片段。在片段 1 中,我有带有位置坐标的数据列表,在片段 2 中,我有地图,它根据位置坐标显示所有数据。
当我单击第一个片段中的特定数据时,我希望应用程序导航到第二个片段并在地图上显示标记并在信息中显示数据 window。
当我点击特定数据时,我可以使用 setcurrentitem()
方法移动到第二个片段。但是我如何只显示该特定位置?
如果有人知道,请给我一个解决方案。我需要尽快完成此操作。
谢谢
当您调用setcurrentitem()
时,将纬度和经度数据传递给Fragment 2,将此代码放在Fragment 1中:
Fragment2 f = new Fragment2();
// Supply value
Bundle args = new Bundle();
args.putLong("latitude", location.getLatitude());
args.putLong("longitude", location.getLongitude());
f.setArguments(args);
在片段 2 中获取值:
Long latitude = getArguments().getLong("latitude", 0);
Long longitude = getArguments().getLong("longitude", 0);
使用 latitude
和 longitude
,您可以在片段 2
的 Google 地图上显示 marker
我有两个使用 View Pager
实现的片段。在片段 1 中,我有带有位置坐标的数据列表,在片段 2 中,我有地图,它根据位置坐标显示所有数据。
当我单击第一个片段中的特定数据时,我希望应用程序导航到第二个片段并在地图上显示标记并在信息中显示数据 window。
当我点击特定数据时,我可以使用 setcurrentitem()
方法移动到第二个片段。但是我如何只显示该特定位置?
如果有人知道,请给我一个解决方案。我需要尽快完成此操作。
谢谢
当您调用setcurrentitem()
时,将纬度和经度数据传递给Fragment 2,将此代码放在Fragment 1中:
Fragment2 f = new Fragment2();
// Supply value
Bundle args = new Bundle();
args.putLong("latitude", location.getLatitude());
args.putLong("longitude", location.getLongitude());
f.setArguments(args);
在片段 2 中获取值:
Long latitude = getArguments().getLong("latitude", 0);
Long longitude = getArguments().getLong("longitude", 0);
使用 latitude
和 longitude
,您可以在片段 2
marker