これは私のmaps_activity.xml
ファイルです。ボタンフィールドを追加しようとすると、エラーMultiple root tags
が表示されます。私はそれが私のGoogleマップのコードでフラグメントレイアウトを使用する必要があります。私はフラグメントレイアウトにボタンを追加するにはどうすればいいですか(GoogleマップAndroidスタジオ)
<Button
android:id="@+id/button"
android:layout_width="146dp"
android:layout_height="wrap_content"
android:text="Open Store" />
を追加しようとすると、私はエラーメッセージ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"
/>
、私はセクションの前にそれを追加してみました、しかし、それはまだ動作しません!
マイMapsActivityクラスのonCreateメソッド
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);
}