我正在使用google map.i成功创建谷歌地图。我可以在谷歌地图中添加标记。但是每一刻都可以,但我有另一个错误。我使用碎片。当我再次去mapFragment我有inflateException。我没有想法我做错了什么这是我的java代码
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.strada_contact, container,
false);
int status = GooglePlayServicesUtil
.isGooglePlayServicesAvailable(getActivity().getBaseContext());
if (status != ConnectionResult.SUCCESS) {
int requestCode = 10;
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status,
getActivity(), requestCode);
dialog.show();
} else {
FragmentManager myFragmentManager = getActivity()
.getFragmentManager();
MapFragment myMapFragment = (MapFragment) myFragmentManager
.findFragmentById(R.id.pointMap);
googleMap = myMapFragment.getMap();
googleMap.setTrafficEnabled(true);
googleMap.setOnMapClickListener(this);
CameraUpdate center = CameraUpdateFactory.newLatLng(new LatLng(
latitude, longitude));
CameraUpdate zoom = CameraUpdateFactory.zoomTo(14);
googleMap.moveCamera(center);
googleMap.animateCamera(zoom);
MarkerOptions marker = new MarkerOptions().position(
new LatLng(latitude, longitude)).title("StradaCafe");
marker.icon(BitmapDescriptorFactory
.fromResource(R.drawable.map_marker));
googleMap.addMarker(marker);
}}
这是我的xml代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="110dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#ffffff" >
<TextView
android:id="@+id/mapstreet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="35dp"
android:layout_marginTop="18dp"
android:gravity="left"
android:text="street" />
<TextView
android:id="@+id/mapcountry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/mapstreet"
android:layout_below="@+id/mapstreet"
android:gravity="left"
android:text="mapcountry" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/relativeLayout1"
android:layout_alignParentLeft="true" >
<ImageView
android:id="@+id/mapimages"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff0000"
/>
<fragment
android:id="@+id/pointMap"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/mapimages"
class="com.google.android.gms.maps.MapFragment" />
</RelativeLayout>
正如我所说,当我再次使用googleMap片段时,我有错误 这是我的logcat错误
如果有人知道解决方案,请帮助我 感谢