How to use google map V2 inside fragment?

后端 未结 9 840
攒了一身酷
攒了一身酷 2020-12-02 13:43

I have a fragment which is a part of Viewpager, and I want to use Google Map V2 inside that fragment. This is what I have tried so far,

In my fragment,



        
9条回答
  •  情深已故
    2020-12-02 14:19

    In link , answer for you:

    "The problem is that what you are trying to do shouldn't be done. You shouldn't be inflating fragments inside other fragments. From Android's documentation:

    Note: You cannot inflate a layout into a fragment when that layout includes a . Nested fragments are only supported when added to a fragment dynamically.

    While you may be able to accomplish the task with the hacks presented here, I highly suggest you don't do it. Its impossible to be sure that these hacks will handle what each new Android OS does when you try to inflate a layout for a fragment containing another fragment.

    The only Android-supported way to add a fragment to another fragment is via a transaction from the child fragment manager."

    For this problem:

    Duplicate ID, tag null, or parent id with another fragment for com.google.android.gms.maps.MapFragment

    For me, the best solution are of @DeepakPanwar

提交回复
热议问题