Android fragmentTransaction.add(R.id.mapView,mMapFragment)不起作用
如何在mapView中添加mapFragment? 为什么这不可行? 我该怎么做才能让它工作:) XMLAndroid fragmentTransaction.add(R.id.mapView,mMapFragment)不起作用,android,fragmenttransaction,Android,Fragmenttransaction,如何在mapView中添加mapFragment? 为什么这不可行? 我该怎么做才能让它工作:) XML android:name="com.google.android.gms.maps.SupportMapFragment" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MapsActivity"
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"/>
无法解析方法addReplace
MapFragment mMapFragment = MapFragment.newInstance();
与
你能发布你的XML吗?@AndyJoyce为什么。。。。他用错了班级。。。FragmentActivity用于支持片段。。。MapFragment扩展了android.app.Fragment。。。编译时错误很明显现在更有趣(愚蠢)。。。。你为什么要替换已经膨胀的碎片?使用v4 FragmentManager.findFragmentById(…)通过其id获取片段,而不是创建(错误的)新片段请检查
com.google.android.gms.maps.SupportMapFragment
我从示例中执行了此操作
MapFragment mMapFragment = MapFragment.newInstance();
MapFragment mMapFragment = new MapFragment();