tags:

views:

17

answers:

1

I have one application. I need to display map view when we click on map button. Actually this map button is in one class and google map is in another class. Now How can we call one map activity class from another activity class.

Please help me!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

A: 

For the button, in the xml layout, set android:clickable="true" and android:onClick="showMap", then in your first activity/class, it's like this:

public void showMap(View v) {
    Intent intent = new Intent(this, Map.class);
    startActivity(intent);
}

(Map.class being the class/name of your activity with the map. You need to adjust the name to your case.)

Mathias Lin
I tried but it cannot display map. In android simulator it displays message android application stopped unexpectedly.
Govardhan Reddy
if you get an error, you need to check the logfile (logcat), either in Eclipse or in command line 'adb shell logcat'. The problem could be anything, hard to say without the log. Or post your code of both the activities and xml layout.
Mathias Lin