片段有新活动吗?

时间:2018-07-19 23:04:55

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

我在这里关注适用于Android的Google地图教程:https://developers.google.com/maps/documentation/android-sdk/current-place-tutorial

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

谢谢。

1 个答案:

答案 0 :(得分:0)

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