I have a frame layout in my fragment layout and I can't access map fragment after I replace the frame layout with map fragment. I am having null pointer exception when I try to access the map after I put it into frame layout.
Here's my related layout:
<FrameLayout
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="15" >
</FrameLayout>
Here's my code in fragment:
private GoogleMap map;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
FragmentManager fm = getChildFragmentManager();
fm.beginTransaction()
.replace(R.id.map, SupportMapFragment.newInstance()).commit();
map = ((SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map))
.getMap();
map.moveCamera(CameraUpdateFactory.newLatLngZoom(KOCAELI, 15));
}