public class MapFragmentOne extends Fragment implements OnMapReadyCallback,
GoogleMap.OnMapClickListener {
private static final int LAYOUT = R.layout.tab_one;
private static View view;
private static GoogleMap mMap;
private SupportMapFragment mapFragment;
private OnGetMap listener;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
LayoutInflater lf = getActivity().getLayoutInflater();
view = lf.inflate(LAYOUT, container, false);
mapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);
if (mapFragment == null) {
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
mapFragment = SupportMapFragment.newInstance();
fragmentTransaction.replace(R.id.map, mapFragment).commit();
}
mapFragment.getMapAsync(this);
return view;
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// А вот здесь не null
Log.d("MAP2", mMap + "");
mMap.getUiSettings().setZoomControlsEnabled(true);
mMap.setBuildingsEnabled(true);
mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
mMap.setIndoorEnabled(true);
mMap.setOnMapClickListener(this);
if (listener != null) {
listener.onGetMap(mMap);
}
}
@Override
public void onMapClick(LatLng point) {
if (mMap != null) {
//Actions on clicks
}
}
public void getMap(OnGetMap listener) {
if (mMap != null) {
listener.onGetMap(mMap);
} else {
this.listener = listener;
}
}
public interface OnGetMap {
void onGetMap(GoogleMap map);
}
}
mapFragmentOne.getMap(new OnGetMap() {
@Override
public void onGetMap(GoogleMap map) {
// do something with map
}
});
SELECT SUM(number) FROM bla_bla_table
Form2 f2 = new Form2();
if (f2.ShowDialog() == DialogResult.OK)
{
TextBox1.Text = "ok";
}
else
{
TextBox1.Text = "";
}
private void Cancel_Click(object sender, EventArgs e)
{
dialogResult = DialogResult.Cancel;
Close();
}
private void OK_Click(object sender, EventArgs e)
{
dialogResult = DialogResult.OK;
Close();
}