At this point I believe you have
1. added necessary permission on manifest
2. added google play service as a lib project
3. api key in manifest file.
where.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.03"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:id="@+id/mapwhere" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
public class WhereFragment extends SupportMapFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
super.onCreateView(inflater, container, savedInstanceState);
View root = inflater.inflate(R.layout.where, null, false);
initilizeMap();
return root;
}
private void initilizeMap()
{
mSupportMapFragment = (SupportMapFragment) getFragmentManager().findFragmentById(R.id.mapwhere);
if (mSupportMapFragment == null) {
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
mSupportMapFragment = SupportMapFragment.newInstance();
fragmentTransaction.replace(R.id.mapwhere, mSupportMapFragment).commit();
}
if (mSupportMapFragment != null)
{
googleMap = mSupportMapFragment.getMap();
if (googleMap != null)
googleMap.setOnMapClickListener(new OnMapClickListener()
{
@Override
public void onMapClick(LatLng point)
{
//TODO: your onclick stuffs
}
});
}
}
}
Documentation:
Nested Fragments
You can now embed fragments inside fragments. This is useful for a variety of situations in which you want to place dynamic and re-usable UI components into a UI component that is itself dynamic and re-usable. For example, if you use ViewPager to create fragments that swipe left and right and consume a majority of the screen space, you can now insert fragments into each fragment page.
To nest a fragment, simply call getChildFragmentManager() on the Fragment in which you want to add a fragment. This returns a FragmentManager that you can use like you normally do from the top-level activity to create fragment transactions. For example, here’s some code that adds a fragment from within an existing Fragment class:
Fragment videoFragment = new VideoPlayerFragment();
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
transaction.add(R.id.video_fragment, videoFragment).commit();
From within a nested fragment, you can get a reference to the parent fragment by calling getParentFragment().
The Android Support Library also now supports nested fragments, so you can implement nested fragment designs on Android 1.6 and higher.
Note: You cannot inflate a layout into a fragment when that layout includes a <fragment>. Nested fragments are only supported when added to a fragment dynamically.
source:http://developer.android.com/about/versions/android-4.2.html#NestedFragments
This will also fix for:
11-06 11:36:01.509: E/AndroidRuntime(6309): FATAL EXCEPTION: main
11-06 11:36:01.509: E/AndroidRuntime(6309): android.view.InflateException: Binary XML file line #9: Error inflating class fragment
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:710)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.LayoutInflater.rInflate(LayoutInflater.java:760)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.LayoutInflater.rInflate(LayoutInflater.java:760)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.LayoutInflater.rInflate(LayoutInflater.java:760)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.LayoutInflater.rInflate(LayoutInflater.java:760)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
11-06 11:36:01.509: E/AndroidRuntime(6309): at com.abc.android.ui.WhereFragment.onCreateView(WhereFragment.java:60)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:927)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:472)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.support.v4.view.ViewPager.populate(ViewPager.java:1068)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.support.v4.view.ViewPager.populate(ViewPager.java:914)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1436)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.View.measure(View.java:16060)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.widget.LinearLayout.measureVertical(LinearLayout.java:847)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.View.measure(View.java:16060)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4923)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.View.measure(View.java:16060)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4923)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.View.measure(View.java:16060)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.widget.LinearLayout.measureVertical(LinearLayout.java:847)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.View.measure(View.java:16060)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4923)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
11-06 11:36:01.509: E/AndroidRuntime(6309): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2414)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.View.measure(View.java:16060)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2133)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1286)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1497)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1183)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4863)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.Choreographer.doFrame(Choreographer.java:532)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.os.Handler.handleCallback(Handler.java:725)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.os.Handler.dispatchMessage(Handler.java:92)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.os.Looper.loop(Looper.java:137)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.app.ActivityThread.main(ActivityThread.java:5328)
11-06 11:36:01.509: E/AndroidRuntime(6309): at java.lang.reflect.Method.invokeNative(Native Method)
11-06 11:36:01.509: E/AndroidRuntime(6309): at java.lang.reflect.Method.invoke(Method.java:511)
11-06 11:36:01.509: E/AndroidRuntime(6309): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
11-06 11:36:01.509: E/AndroidRuntime(6309): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
11-06 11:36:01.509: E/AndroidRuntime(6309): at dalvik.system.NativeStart.main(Native Method)
11-06 11:36:01.509: E/AndroidRuntime(6309): Caused by: java.lang.IllegalStateException: Fragment com.google.android.gms.maps.SupportMapFragment did not create a view.
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:314)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:682)
1. added necessary permission on manifest
2. added google play service as a lib project
3. api key in manifest file.
where.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1.03"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:id="@+id/mapwhere" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
public class WhereFragment extends SupportMapFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
super.onCreateView(inflater, container, savedInstanceState);
View root = inflater.inflate(R.layout.where, null, false);
initilizeMap();
return root;
}
private void initilizeMap()
{
mSupportMapFragment = (SupportMapFragment) getFragmentManager().findFragmentById(R.id.mapwhere);
if (mSupportMapFragment == null) {
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
mSupportMapFragment = SupportMapFragment.newInstance();
fragmentTransaction.replace(R.id.mapwhere, mSupportMapFragment).commit();
}
if (mSupportMapFragment != null)
{
googleMap = mSupportMapFragment.getMap();
if (googleMap != null)
googleMap.setOnMapClickListener(new OnMapClickListener()
{
@Override
public void onMapClick(LatLng point)
{
//TODO: your onclick stuffs
}
});
}
}
}
Documentation:
Nested Fragments
You can now embed fragments inside fragments. This is useful for a variety of situations in which you want to place dynamic and re-usable UI components into a UI component that is itself dynamic and re-usable. For example, if you use ViewPager to create fragments that swipe left and right and consume a majority of the screen space, you can now insert fragments into each fragment page.
To nest a fragment, simply call getChildFragmentManager() on the Fragment in which you want to add a fragment. This returns a FragmentManager that you can use like you normally do from the top-level activity to create fragment transactions. For example, here’s some code that adds a fragment from within an existing Fragment class:
Fragment videoFragment = new VideoPlayerFragment();
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
transaction.add(R.id.video_fragment, videoFragment).commit();
From within a nested fragment, you can get a reference to the parent fragment by calling getParentFragment().
The Android Support Library also now supports nested fragments, so you can implement nested fragment designs on Android 1.6 and higher.
Note: You cannot inflate a layout into a fragment when that layout includes a <fragment>. Nested fragments are only supported when added to a fragment dynamically.
source:http://developer.android.com/about/versions/android-4.2.html#NestedFragments
This will also fix for:
11-06 11:36:01.509: E/AndroidRuntime(6309): FATAL EXCEPTION: main
11-06 11:36:01.509: E/AndroidRuntime(6309): android.view.InflateException: Binary XML file line #9: Error inflating class fragment
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:710)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.LayoutInflater.rInflate(LayoutInflater.java:760)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.LayoutInflater.rInflate(LayoutInflater.java:760)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.LayoutInflater.rInflate(LayoutInflater.java:760)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.LayoutInflater.rInflate(LayoutInflater.java:760)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
11-06 11:36:01.509: E/AndroidRuntime(6309): at com.abc.android.ui.WhereFragment.onCreateView(WhereFragment.java:60)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:927)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:472)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.support.v4.view.ViewPager.populate(ViewPager.java:1068)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.support.v4.view.ViewPager.populate(ViewPager.java:914)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1436)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.View.measure(View.java:16060)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.widget.LinearLayout.measureVertical(LinearLayout.java:847)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.View.measure(View.java:16060)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4923)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.View.measure(View.java:16060)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4923)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.View.measure(View.java:16060)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.widget.LinearLayout.measureVertical(LinearLayout.java:847)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.View.measure(View.java:16060)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4923)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
11-06 11:36:01.509: E/AndroidRuntime(6309): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2414)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.View.measure(View.java:16060)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2133)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1286)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1497)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1183)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4863)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.Choreographer.doFrame(Choreographer.java:532)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.os.Handler.handleCallback(Handler.java:725)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.os.Handler.dispatchMessage(Handler.java:92)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.os.Looper.loop(Looper.java:137)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.app.ActivityThread.main(ActivityThread.java:5328)
11-06 11:36:01.509: E/AndroidRuntime(6309): at java.lang.reflect.Method.invokeNative(Native Method)
11-06 11:36:01.509: E/AndroidRuntime(6309): at java.lang.reflect.Method.invoke(Method.java:511)
11-06 11:36:01.509: E/AndroidRuntime(6309): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
11-06 11:36:01.509: E/AndroidRuntime(6309): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
11-06 11:36:01.509: E/AndroidRuntime(6309): at dalvik.system.NativeStart.main(Native Method)
11-06 11:36:01.509: E/AndroidRuntime(6309): Caused by: java.lang.IllegalStateException: Fragment com.google.android.gms.maps.SupportMapFragment did not create a view.
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:314)
11-06 11:36:01.509: E/AndroidRuntime(6309): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:682)