In my application am use include other layout to include two view in main XML,in that first view have simple text view only and in second view i have map view.In my main XML file i have two buttons when i click first button to show first view with text view,when i click second button i want to hide the first view and to show second view with map view.I don't know how to show the map view in main activity.Can any one know please help me to solve this problem.
-
didnt get your question properly. – Sagar Maiyad Jun 15 '13 at 11:38
-
@Segi i want to show map-view in activity. – Yugesh Jun 15 '13 at 11:40
3 Answers
Firstly tell what version of google maps do you use v1 - https://developers.google.com/maps/documentation/android/v1/ v2 - https://developers.google.com/maps/documentation/android/start
Usually what you need to do is to put you two layouts inside FrameLayout and show/hide one of them when you click on particular button. But to be more specific we need to see your code.

- 7,166
- 8
- 40
- 64
1) MapView is used by GoogleMapsV1. But it needs an api key provided by google for individual developers upon registration.
Unfortunately, which is closed by google and you have to use GoogleMapV2 with new V2 key.
Also, workout with fragments because, here we are using Fragment or SupportFragment.
2) You can use a FrameLayout inside which your two overlapped views with id's. So that you can show or hide views at same position as you need.

- 5,698
- 9
- 45
- 57
Please try to use bellow code.
<LinearLayout
android:id="@+id/buttonLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="button1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="button2" />
</LinearLayout>
<ViewFlipper
android:id="@+id/viewFliper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/buttonLayout" >
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.google.android.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:apiKey="your map key map_key"
android:clickable="true"
android:enabled="true"
android:focusable="true"
android:focusableInTouchMode="true" />
</ViewFlipper>

- 834
- 1
- 5
- 10