Hi, I am trying an Mapapplication, its working for me alone.but i
want to call a mapactivity after a button click of an main activity, i
tried it with intents and onclick method, but it doesnt works for me.i
ll show my code here,
main activity.java
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.MultiAutoCompleteTextView;
import android.widget.TextView;
public class popup extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.address);
TextView txt1=(TextView)findViewById(R.id.multiAutoCompleteTextView1);
txt1.setTextSize(15);
MultiAutoCompleteTextView
mact=(MultiAutoCompleteTextView)findViewById(R.id.multiAutoCompleteTextView2);
mact.setLines(20);
mact.setTextSize(12);
mact.setTextColor(Color.MAGENTA);
mact.setText(" 909 San Antonio Ave. \n Alameda \n CA \n US \n
94501-3959 \n \n Phone: (510) 864-0435 \n Fax: (415) 651-8787
\n \n Customer Support Services \n (415) 508-3645 \n
[email protected] \n \n Sales and Project
Management \n Aaron Delloiacono Thies \n (510) 864-0435 \n
[email protected] \n ");
Button btn=(Button)findViewById(R.id.imageButton1);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i=new Intent(popup.this.getBaseContext(), map.class);
startActivity(i);
}
});
}
}
MapAcitivity.java
import java.util.ArrayList;
import java.util.List;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.KeyEvent;
import android.widget.Toast;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;
import com.google.android.maps.OverlayItem;
public class map extends MapActivity{
private MapView map=null;
private MyLocationOverlay me=null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
map=(MapView)findViewById(R.id.map1);
map.getController().setCenter(getPoint(37.769585,
-122.270117));
map.getController().setZoom(17);
map.setBuiltInZoomControls(true);
Drawable marker=getResources().getDrawable(R.drawable.m);
marker.setBounds(0, 0, marker.getIntrinsicWidth(),
marker.getIntrinsicHeight());
map.getOverlays().add(new SitesOverlay(marker));
me=new MyLocationOverlay(this, map);
map.getOverlays().add(me);
}
@Override
public void onResume() {
super.onResume();
me.enableCompass();
}
@Override
public void onPause() {
super.onPause();
me.disableCompass();
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_S) {
map.setSatellite(!map.isSatellite());
return(true);
}
else if (keyCode == KeyEvent.KEYCODE_Z) {
map.displayZoomControls(true);
return(true);
}
return(super.onKeyDown(keyCode, event));
}
private GeoPoint getPoint(double lat, double lon) {
return(new GeoPoint((int)(lat*1000000.0),
(int)(lon*1000000.0)));
}
public class SitesOverlay extends ItemizedOverlay<OverlayItem> {
private List<OverlayItem> items=new ArrayList<OverlayItem>();
public SitesOverlay(Drawable marker) {
super(marker);
boundCenterBottom(marker);
items.add(new OverlayItem(getPoint(37.769585,
-122.270117),
"Ad Delivery Solution ", " Ad Delivery Solution-
Welcomes you"));
marker=getResources().getDrawable(R.drawable.greendot);
items.add(new OverlayItem(getPoint(37.769625,
-122.269453),
"hi"," you are in San Antonio Ave"));
marker=getResources().getDrawable(R.drawable.greendot);
items.add(new OverlayItem(getPoint( 37.769832,
-122.270109),
"hi"," you are near to Ad Delivery Solution"));
marker=getResources().getDrawable(R.drawable.greendot);
items.add(new OverlayItem(getPoint(37.769573,
-122.269575),
"Ad delivery solution",
"Official Zone"));
populate();
}
@Override
protected OverlayItem createItem(int i) {
return(items.get(i));
}
@Override
protected boolean onTap(int i) {
Toast.makeText(map.this,
items.get(i).getSnippet(),
Toast.LENGTH_SHORT).show();
return(true);
}
@Override
public int size() {
return(items.size());
}
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
address.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:background="@drawable/home"
android:layout_height="fill_parent"
>
<TableLayout android:id="@+id/frameLayout1"
android:layout_marginTop="50dp" android:layout_height="wrap_content"
android:layout_width="match_parent">
<TextView android:textColor="#000000"
android:background="#FFFFFF" android:layout_marginLeft="80dp"
android:layout_marginRight="80dp"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_width="match_parent" android:text=" Contact US"
android:id="@+id/multiAutoCompleteTextView1"
android:layout_height="wrap_content"></TextView>
<MultiAutoCompleteTextView android:editable="false"
android:layout_marginTop="5dp" android:layout_width="match_parent"
android:text="" android:id="@+id/multiAutoCompleteTextView2"
android:layout_height="wrap_content"></MultiAutoCompleteTextView>
<Button android:background="@drawable/logo"
android:onClick="MapEvent" android:layout_marginTop="5dp" android:id="@
+id/imageButton1" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_width="wrap_content"></
Button>
</TableLayout>
</LinearLayout>
main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:layout_width="fill_parent"
android:background="@drawable/blk"
android:layout_height="fill_parent">
<com.google.android.maps.MapView android:id="@+id/map1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="0Tmp01s94JxElcT_KAsk64vI4uP1xnN37U2yoJA"
android:clickable="true" />
</RelativeLayout>
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.paad.popup"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-
permission>
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"></uses-
permission>
<uses-permission
android:name="android.permission.ACCESS_MOCK_LOCATION"></uses-
permission>
<uses-permission android:name="android.permission.INTERNET"></uses-
permission>
<application android:icon="@drawable/icon" android:label="@string/
app_name">
<activity android:name=".popup"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<supports-screens android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
<uses-library android:name="com.google.android.maps" />
</application>
</manifest>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en