0

I am developing app with map in viewPager, I followed the second part of this answer and every thing is ok. Now I need the view to be map with button.

This is the .xml code

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:orientation="vertical">

    <fragment xmlns:android="http://schemas.android.com/apk/red/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/map"
        android:layout_height="match_parent"
        android:layout_weight="0.1"
        android:layout_width="match_parent"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        tools:context="com.developers.redfinger.mymap.MainMapActivity"></fragment>

    <Button
        android:id="@+id/bAdd"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.9"
        android:paddingTop="5dp"
        android:text="Add Place"
        android:textSize="28dp" />
</LinearLayout>

When I override onCreatView() as first part of answer to define button the unfortunately stop, any help please.

Community
  • 1
  • 1
Tefa
  • 328
  • 1
  • 4
  • 15
  • @DanielNugent Ok this is very good, I am really sorry this my last question when I extend FragmentActivity in MapFragment class , in the inner class pagerAdapter in MainActivity the method getItem() returns a Fragment not FragmentActivity I cannot handle this. And thanks for all your reply to me – Tefa Jun 06 '16 at 18:51
  • 1
    I just realized that since you're using a SupportMapFragment subclass in a ViewPager, you'll probably need to add the button in code instead of using a layout xml file. Another option is to use a nested SupportMapFragment and inflate a layout that has both the map and the button, but nesting Fragments should be avoided if possible. – Daniel Nugent Jun 06 '16 at 19:21
  • @DanielNugent if you can give me details for this second option I will be very thankful. And I will try to add it in code of course – Tefa Jun 06 '16 at 19:28
  • @DanielNugent Is this what you meant http://stackoverflow.com/a/25051469/5939718 – Tefa Jun 06 '16 at 19:33

0 Answers0