안드로이드 개발 질문/답변
(글 수 45,052)
package com.he.hel;
import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.util.Log;
public class way_sam extends Activity{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.way);
Log.i("TAG", "ok");
Intent intent = new Intent(getBaseContext(), GoogleMapSample.class);
intent.putExtra("menu", 2);
startActivity(intent);
}
}
package com.he.hel;
import com.google.android.maps.GeoPoint; import com.google.android.maps.MapActivity; import com.google.android.maps.MapController; import com.google.android.maps.MapView;
import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.widget.Toast;
public class GoogleMapSample extends MapActivity {
/** Called when the activity is first created. */
/**
* Request code defined for Another Activity
*/
//public static final int REQUEST_CODE_ANOTHER = 1001;
public int HpIndex;
MapView map_view;
MapController mapControl;
GeoPoint point[] = new GeoPoint[9];
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.maphwa);
Intent intent = getIntent();
HpIndex = intent.getExtras().getInt("menu");
point[0] = new GeoPoint((int)(37.3478338 * 1000000.0), (int)(127.1243797 * 1000000.0));
point[1] = new GeoPoint((int)(37.4888793 * 1000000.0), (int)(127.0864968 * 1000000.0));
point[2] = new GeoPoint((int)(36.3550408 * 1000000.0), (int)(127.3820047 * 1000000.0));
point[3] = new GeoPoint((int)(37.5403974 * 1000000.0), (int)(127.0720953 * 1000000.0));
point[4] = new GeoPoint((int)(37.5263521 * 1000000.0), (int)(127.1096752 * 1000000.0));
point[5] = new GeoPoint((int)(36.3253046 * 1000000.0), (int)(127.4212387 * 1000000.0));
point[6] = new GeoPoint((int)(35.09773 * 1000000.0), (int)(129.0241207 * 1000000.0));
point[7] = new GeoPoint((int)(35.0582484 * 1000000.0), (int)(127.0026093 * 1000000.0));
point[8] = new GeoPoint((int)(35.8693527 * 1000000.0), (int)(128.6061666 * 1000000.0));
map_view = (MapView)findViewById(R.id.map_view);
mapControl = map_view.getController();
mapControl.setZoom(15);
map_view.setBuiltInZoomControls(true);
//point = new GeoPoint((int)(37.3478338 * 1000000.0), (int)(127.1243797 * 1000000.0));
mapControl.animateTo(point[HpIndex]);
}
/*protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_CODE_ANOTHER) {
Toast toast = Toast.makeText(getBaseContext(), "onActivityResult called with code : " + resultCode, Toast.LENGTH_LONG);
toast.show();
if (resultCode == 1) {
int index = data.getExtras().getInt("menu");
HpIndex = index;
toast = Toast.makeText(getBaseContext(), "result HpIndex : " + HpIndex, Toast.LENGTH_LONG);
toast.show();
}
}
}*/
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}<?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:layout_height="fill_parent"
>
<com.google.android.maps.MapView
android:id="@+id/map_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="0QRqN8u1C0aOd28e4tSdwnjFqWNA4Ly-C0H4cvQ"
/>
</LinearLayout> 순서대로 클래스가 생성되면인텐트로 맵 화면을 띄우는 창을 불러오고
맵을 보여주는 맵뷰 xml 입니다...
기존의 프로젝트에서는 되는데
타 프로젝트에 삽입하려고 옮겨오면 에러가 납니다;;
googleAPI도 같고 여러가지를 다 전 프로젝트와 똑같이 햇습니다...



