【发布时间】:2017-09-17 05:09:46
【问题描述】:
这是我的maps_activity.xml 文件,当我尝试添加按钮字段时,我收到错误Multiple root tags。
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
当我尝试添加时
<Button
android:id="@+id/button"
android:layout_width="146dp"
android:layout_height="wrap_content"
android:text="Open Store" />
我收到一条错误消息Multiple root tags。
直到 onCreate 方法之前的我的 MapsActivity 类
public class MapsActivity extends AppCompatActivity
implements OnMapReadyCallback,
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener,
com.google.android.gms.location.LocationListener{
GoogleMap mGoogleMap;
SupportMapFragment mapFrag;
LocationRequest mLocationRequest;
GoogleApiClient mGoogleApiClient;
Location mLastLocation;
Marker mCurrLocationMarker;
Marker marker;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
getSupportActionBar().setTitle("Map Location Activity");
mapFrag = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFrag.getMapAsync(this);
}
谢谢!
【问题讨论】:
标签: android google-maps android-fragments