如何在mapView中添加mapFragment? 为什么这不起作用? 我该怎么办呢?)?
public class MapsActivity extends FragmentActivity {
// ..............................................
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
MapFragment mMapFragment = MapFragment.newInstance();
fragmentTransaction.add(R.id.mapView, mMapFragment);
fragmentTransaction.commit();
XML
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapsActivity"
tools:layout="@layout/activity_maps"
class="com.google.android.gms.maps.SupportMapFragment"/>
无法解析方法添加
答案 0 :(得分:-1)
替换
MapFragment mMapFragment = MapFragment.newInstance();
带
MapFragment mMapFragment = new MapFragment();