안드로이드 개발 질문/답변
(글 수 45,052)
MapActivity로 만든 클래스를 따로 두고 다른 Activity 들에서 가져다 쓸 수 있는 방법이
궁급합니다. 아래 그림에서 왼쪽은 완성해서 실행했을때 이고
오른쪽은 기본 메인 Activity 라고 했을시 어떤식으로 코딩해야하는지 혹시 도와주실분 계신가요?
오른쪽 그림처럼 text만 있는 클래스를 하나 만들고 구글맵을 가져온 클래스는 따로 존재해서
왼쪽 그림처럼 합치는 방식이요. 제가 진짜 별에 별 짓을 다해봤는데 도저히 못하겠습니다 ㅠㅠ
혹시 코딩 가능하시면 소스좀 대략적으로나마 알려주시면 안될까요?
아니면 그냥 어떤걸 이용하라고 라도 좋습니다. 조금만 구체적으로 꼭 좀 부탁드립니다.
그림 첨부하여 글 수정하였습니다.
//공지사항을 다 읽었음.
2010.04.30 16:05:03
맵 관련 클래스를 만든 다음에 그 객체를 가지고 여러 액티비티에서 가져다 쓰시면 됩니다. 크기가 다른 부분은 네이티브 코딩으로 layout 을 액티비티마다 다뤄도 되고 xml layout 으로 별도로 여러가지 레이아웃을 만든 다음에 그 레이아웃별로 액티비티에 setContentView 를 사용하시면 될겁니다.
2010.04.30 23:07:38
별도로 맵 관련 레이아웃만 작성해서
<com.google.android.maps.MapView
android:id="@+id/map_View"
android:clickable="true"
//android:apiKey="0xUB84qXpsiv8JbS6exitbD7s-j5FRwos-Q3Pyw"
android:layout_width="fill_parent"
android:layout_gravity="top"
android:layout_height="fill_parent"/>
빈 공간이 있는 액티비티를 만들고 빈공간 부분을 레이아웃(리니어나 기타.. )으로 정합니다. @+id/emptySpace 등으로 정해놓고 코드로 LinearLayout l = (LinearLayout) findViewById(R.id.emptySpace); 등으로 가져온 다음에
MapView mapView = (MapView) findViewById(R.id.map_View);
mapView.setSatellite(false); // satellite 위 true
mapView.setMinimumHeight(100);
MapController mc = mapView.getController();
l.addView(mapView);
뭐 대충 이런식으로 구현하면 되지 않을까 싶네요.
대충 생각해낸거라 잘 될지는...;
<com.google.android.maps.MapView
android:id="@+id/map_View"
android:clickable="true"
//android:apiKey="0xUB84qXpsiv8JbS6exitbD7s-j5FRwos-Q3Pyw"
android:layout_width="fill_parent"
android:layout_gravity="top"
android:layout_height="fill_parent"/>
빈 공간이 있는 액티비티를 만들고 빈공간 부분을 레이아웃(리니어나 기타.. )으로 정합니다. @+id/emptySpace 등으로 정해놓고 코드로 LinearLayout l = (LinearLayout) findViewById(R.id.emptySpace); 등으로 가져온 다음에
MapView mapView = (MapView) findViewById(R.id.map_View);
mapView.setSatellite(false); // satellite 위 true
mapView.setMinimumHeight(100);
MapController mc = mapView.getController();
l.addView(mapView);
뭐 대충 이런식으로 구현하면 되지 않을까 싶네요.
대충 생각해낸거라 잘 될지는...;