을보십시오이
XML에서 내지도이
과 같은
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.home_fragment, container, false);
Bundle bdl = getArguments();
// setuping locatiomanager to perfrom location related operations
locationManager = (LocationManager) getActivity().getSystemService(
Context.LOCATION_SERVICE);
// Requesting locationmanager for location updates
locationManager.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER, 1, 1, this);
// To get map from MapFragment from layout
googleMap = ((MapFragment) getActivity().getFragmentManager()
.findFragmentById(R.id.map)).getMap();
// To change the map type to Satellite
// googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
// To show our current location in the map with dot
// googleMap.setMyLocationEnabled(true);
// To listen action whenever we click on the map
googleMap.setOnMapClickListener(new OnMapClickListener() {
@Override
public void onMapClick(LatLng latLng) {
/*
* LatLng:Class will give us selected position lattigude and
* longitude values
*/
Toast.makeText(getActivity(), latLng.toString(),
Toast.LENGTH_LONG).show();
}
});
changeMapMode(3);
// googleMap.setSatellite(true);
googleMap.setTrafficEnabled(true);
googleMap.setBuildingsEnabled(true);
googleMap.setMyLocationEnabled(true);
return v;
}
이 같은개
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tag="ScrewMaps" />
내가 분리하고 조각 : -
@Override
public void onDestroyView() {
// TODO Auto-generated method stub
super.onDestroyView();
locationManager.removeUpdates(this);
android.app.Fragment fragment = getActivity().getFragmentManager()
.findFragmentById(R.id.map);
if (null != fragment) {
android.app.FragmentTransaction ft = getActivity()
.getFragmentManager().beginTransaction();
ft.remove(fragment);
ft.commit();
}
}
내지도보기 조각이 android.app.Fragment & 나는() 추가하고 MapViewFragment을 제거하기 위해 getFragmentManager을 사용하고 있음을 유의하시기 바랍니다. V4.Fragment 작업을 app.Fragment와 혼합하면 앱이 심하게 다운됩니다.
Ah finnaly. 그것은 작동, 당신은 내 하루를 구했습니다. –
당신을 진심으로 환영합니다. BTW : 해결 된 질문에 [해체]를 추가 할 필요가 없습니다. 간단히 대답을 받아 들여 가장 도움이되었습니다. 사이트가 나머지 부분을 처리합니다. 또한 수용도가 높으면 사람들이 귀하의 질문에 답할 확률이 높아집니다. – keyboardsurfer