john john - 24 days ago 8
Android Question

Is it possible to add a button in " google maps activity" to pass control to another activity?

I am new to android, i want to add the Google map for displaying users current location, i have done it with Google maps activity,.Now what i need is, i have to enable an option to input a destination ,so i want to add a button in that map layout.Is it possible?if possible how can i add this.I selected this layout.

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/map" tools:context=".MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment"
tools:layout="@layout/abc_list_menu_item_radio" />

Answer

yes for that take one relative layout and put the fragment and your button in the relative layout. Try this code may be it will help you..

<RelativeLayout 
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent">

   <fragment xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:id="@+id/map"
     android:name="com.google.android.gms.maps.SupportMapFragment"
     android:layout_width="match_parent"
     android:layout_height="500dp"
     tools:context=".MapsActivity"
     tools:layout="@layout/abc_list_menu_item_radio" />

  <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Button"
    android:id="@+id/button"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true" />
</RelativeLayout>