【问题标题】:Passing latitude and longitude from one fragment to another fragment [duplicate]将纬度和经度从一个片段传递到另一个片段[重复]
【发布时间】:2018-02-27 07:13:18
【问题描述】:

地图和片段

这是我的设计 图片

我有两个片段。FirstFragment -> 地图和 SecondFragment -> 天气

我从下面的代码中的第一个片段获取纬度和经度:

mPlace.setLatlng(place.getLatLng());

在 SecondFragment 中,我在此代码上执行纬度和经度:

asyncTask.execute("10.873873","78.818729");

问题:我想将经纬度从我的 FirstFragment 传递到 SecondFragment。

我尝试使用带有参数的 Bundle 来传递数据。它不起作用。

【问题讨论】:

标签: java android google-maps android-studio android-fragments


【解决方案1】:

如果您的 Activity 将只有每个 Fragment 的一个副本,那么您可以简单地让 Activity 保存 LatLng 变量,并且可以从两个 Fragment 访问它。

【讨论】:

  • 谢谢你@lion。如果我在地图(fragment1)中选择一个特定位置。我必须在我的fragment2中获取该位置的天气。尝试过的接口和捆绑它们不起作用。还有其他的吗大大地??步骤是什么???
  • @shyam 通知 Activity,并让 Activity 通知 Fragment2。
  • 谢谢你我会通知@lionscribe
猜你喜欢
  • 2016-06-12
  • 2020-05-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多