Reputation:
I have updated the android SDK to 5.0 and my previous project is not working on it(which worked correctly in 4.4.2).
I have an class which extends fragment
public class MapFragment extends Fragment{
//
}
In this class i have inflated a layout with google support mapfragment
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map_tile_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible" >
<RelativeLayout
android:id="@+id/full_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
<Textview
<!-- dfh
fgh -->
/>
</RelativeLayout>
</RelativeLayout>
When i do this in my code it return null
SupportMapFragment fragment = (SupportMapFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.map);
This same line worked for me in Android4.4.2 but after updation there is some problem...
Do anyone found the solution...
Upvotes: 1
Views: 1888
Reputation:
I've found the answer and it works for me
Instead of this
SupportMapFragment fragment = (SupportMapFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.map);
I've changed as
SupportMapFragment fragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map);
Upvotes: 10