Wednesday, November 6, 2013

how to display MapFragment inside the fragment(NestedFragment):

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)

11 comments:

  1. https://local.google.com/place?id=18130935100246037027&use=posts&lpsid=873543174592864879
    https://local.google.com/place?id=13229671129642351498&use=posts&lpsid=3538948487215596960
    In such scenarios while getting stuck with any sort of technical or non-technical grievances in QuickBooks, simply call us on our QuickBooks Support Phone Number California +1(844)233-3033, and acquire exceptional accounting services from our executives. Our experts are skilled enough to answer all of the error codes users ask for.
    QuickBooks Desktop Support +1(844)233-3033
    QuickBooks Enterprise Support +1(844)233-3033
    Quickbooks 24/7 Customer service +1(844)233-3033
    Quickbooks Payroll Support +1(844)233-3033
    QuickBooks Technical Support +1(844)233-3033
    QuickBooks POS Support +1(844)233-3033

    ReplyDelete
  2. Türkiye'nin en güvenilir takipçi satış platformu : takipçi satın al

    İnstagram takipçi mi almak istiyorsun sadece tıkla : instagram takipçi satın al

    Tiktokta fenomen olmaya hazır mısın işte seçenekler : tiktok takipçi satın al

    2 . takipçi satın alma linki : takipçi satın al

    3 . takipçi satın alma linki : takipçi satın al

    ReplyDelete
  3. Hey! What a wonderful blog. I loved your blog. QuickBooks is the best accounting software, however, it has lots of bugs like QuickBooks Error. To fix such issues, you can contact experts via QuickBooks Customer Support Number

    ReplyDelete
  4. Hey! Fabulous post. It is the best thing that I have read on the internet today. Moreover, if you need instant support for QuickBooks Error, visit at QuickBooks Customer Service Phone Number Our team is always ready to help and support their clients.

    ReplyDelete
  5. Experiencing QuickBooks errors while using it? Connect with us at QuickBooks Customer Support Phone Number - Illinois USA+1(866) 548-1059 today and avail the benefits of QuickBooks. We can help fix your issues instantly.

    ReplyDelete
  6. If you are searching the best QB experts, you can contact us at QuickBooks Customer Support Phone Number -Nevada USA+1(888) 711-8718. Our team will help you and provide you the best solution according to your need.

    ReplyDelete
  7. QuickBooks Error 6190 and 816, you need an expert technical support. Here, we offer a nonstop QuickBooks solution that can help you settle your errors. Find the best solution to your QuickBooks errors. Our group of experts are QB certified and holding longer than a time of expertise in tackling issues in QB software. Thus, if you are looking for the right QB consultants, you can speak with our experts at QuickBooks Customer Support Service Phone Number - Texas+1(888) 805-3924

    ReplyDelete
  8. Our group of experts are QB certified and holding longer than a time of expertise in tackling issues in QB software. Thus, if you are looking for the right QB consultants, you can speak with our experts at Quickbooks Phone Number +1(888) 450-5130

    ReplyDelete