你可以透過com.google.android.maps.MapActivity輕鬆使用Google map。
1.
mapdemo.java:將Acitivity改為MapAcitivity如籃色部份,MapAcitivity是Google map使用的class。
package com.test.demo;
import com.google.android.maps.MapActivity; import android.os.Bundle;
public class mapdemo extends MapActivity{ /** Called when the activity is first created. */ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); } }
|
2.
main.xml:將TextView的xml部份換成籃色部份,請注意MapView的部份都是如此定義標籤。
<?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" > <view id="@+id/my_map" class="com.google.android.maps.MapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" /> </LinearLayout>
|
1 則留言:
您好^_^ 有很多有關android的問題可以請教您嗎?
請問有沒有msn可以與您聊聊呢?
張貼留言