import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.SupportMapFragment; public class Fragment1 extends Fragment { SupportMapFragment mapFragment; GoogleMap map; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment1, container, false); mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); map = mapFragment.getMap(); if (map == null) { finish(); } return rootView; } } 1 ошибка - The method getSupportFragmentManager() is undefined for the type Fragment1 Fragment1.java /Reea/src/com/skaaaa line 25 Java Problem 2 ошибка The method finish() is undefined for the type Fragment1 Fragment1.java /Reea/src/com/skaaaa line 29 Java Problem
|
2 answers
getFragmentManager()
getActivity().finish()
|
in order for getSupportFragmentManager () to be available, the fragment must be launched from the activity inherited from FragmentActivity and SupportFragmentManager is not the fragment, but the activation
getActivity().getSupportFragmentManager();
- It is enough to call
getFragmentManager()
from the fragment, which will lead to exactly the same result. - falstaf
|