【问题标题】:New activity for fragment?片段的新活动?
【发布时间】:2018-07-19 23:04:55
【问题描述】:

我正在关注 Android 的谷歌地图教程:https://developers.google.com/maps/documentation/android-sdk/current-place-tutorial

我的问题是,一旦我进入“添加地图”部分,该代码是我片段的 java 的代码吗?还是第一部分的主要java?

谢谢。

【问题讨论】:

  • 是的,对于您的主要 java 文件也是如此,这将是您的主要活动文件。您可以在任何您想要的活动或片段中添加地图。

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


【解决方案1】:
the doc clearly says that 
"
Add a <fragment> element to your activity's layout file, activity_maps.xml.  "

so the the "activity_maps.xml" is the activity layout file and the following code should be inside the "activity_maps.xml"


<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.currentplacedetailsonmap.MapsActivityCurrentPlace" />

如果您觉得有帮助,请参考此链接

https://stackoverflow.com/questions/20314635/android-map-in-fragment

【讨论】:

  • 我说的是java
  • @samuelJohnson ..对不起,我在你的问题中迷失了......是的..它是你的活动 java 文件
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-02
  • 1970-01-01
相关资源
最近更新 更多