Issue
I am trying to display map in Android for the first time.
Now I want to display 3 buttons on the map, and when I clicked on a particular button, that button's click event should be raised.
The map should be in full-screen and buttons are at the below side.
I don't know how I do this? When we want to display map using a MapView we have to extends the MapActivity class. So please suggest some ideas, examples or reference sites.
Edited:
I have displayed map using the following Layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.google.android.maps.MapView
android:id="@+id/mapView01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:enabled="true"
android:clickable="true"
android:apiKey="my generated api key"
/>
<Button
android:text="Button"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
</LinearLayout>
Solution
Praveen's answer is fine. Just keep in mind that one of the greatest avantages of RelativeLayout
is that you can avoid unnecessary nesting. The more simple your layout, the easier to maintain it is. This is equivalent to Praveen's answer:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/mapview"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:clickable="true" android:apiKey="your_id" />
<Button android:layout_below="@+id/mapview"
android:text="@+id/Button03"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"/>
<Button android:layout_below="@+id/mapview"
android:text="@+id/Button02"
android:id="@+id/Button02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"/>
<Button android:text="@+id/Button03"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_toLeftOf="@+id/mapview"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
Answered By - Cristian
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.