欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
傳遞坐標到Google地圖(轉) - 源碼代碼下載 - CMD100 中國手機開(kāi)發(fā)者聯(lián)盟
在本節中,你將繼續在前一節的基礎上構造。對AndroidLBS活動(dòng)的主要修改就是傳遞坐標到Google地圖中。你將使用Google地圖來(lái)顯示用戶(hù)的當前位置。在main.xml文件中的唯一修改指出就是為MpaView增加一個(gè)布局。在目前版本的Android SDK中,MapView被建立為一個(gè)類(lèi)View??赡茉趯?lái)的版本中MapView會(huì )相當于這個(gè)布局。
<view class="com.google.android.maps.MapView"
android:id="@+id/myMap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
完成后的main.xml文件應當像這樣:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
androidrientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="@+id/gpsButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Where Am I"
/>
<LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/latLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Latitude: "
/>
<TextView
android:id="@+id/latText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/lngLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Longitude: "
/>
<TextView
android:id="@+id/lngText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
<view class="com.google.android.maps.MapView"
android:id="@+id/myMap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
因為在這個(gè)活動(dòng)中嵌入MapView,你需要改變類(lèi)的定義?,F在,主要類(lèi)擴展了活動(dòng)。但是要正確的使用Google MapView,你必須擴展MapActivity。因此,你需要輸入MapActivity包裝并且替換在頭部的Activity 包裝。
輸入下列包裝:
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Point;
import com.google.android.maps.MapController
Point包裝將被用于保留point的值,它就是展示地圖坐標的,而MapController將你的point置于地圖中央。這兩個(gè)包裝在使用MapView時(shí)非常的關(guān)鍵。
現在準備增加建立地圖并傳遞坐標的代碼。首先,設置一個(gè)一個(gè)MapView,并且從main.xml文件中把它賦值到布局:
MapView myMap = (MapView) findViewById(R.id.myMap);
下一步,設置一個(gè)Point并且把從GPS檢索的數值賦值給latPoint和IngPoint:
Point myLocation = new Point(latPoint.intValue(),lngPoint.intValue());
現在,可以創(chuàng )建MapController了,它將被用于移動(dòng)Google地圖來(lái)定位你定義的Point。從MapView使用getController()方法在定制的地圖中建立一個(gè)控制器:
MapController myMapController = myMap.getController();
唯一剩下的工作就是使用控制器來(lái)移動(dòng)地圖到你的位置(要讓地圖更容易辨認,把zoom設定為9):
myMapController.centerMapTo(myLocation, false);
myMapController.zoomTo(9);
你剛才所寫(xiě)的所有代碼就是從活動(dòng)中利用Google地圖。完整的類(lèi)應當像這樣:
package android_programmers_guide.AndroidLBS;
import android.os.Bundle;
import android.location.LocationManager;
import android.view.View;
import android.widget.TextView;
import android.content.Context;
import android.widget.Button;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Point;
import com.google.android.maps.MapController;
public class AndroidLBS extends MapActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
final Button gpsButton = (Button) findViewById(R.id.gpsButton);
gpsButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v){
LoadProviders();
}});
}
public void LoadProviders(){
TextView latText = (TextView) findViewById(R.id.latText);
TextView lngText = (TextView) findViewById(R.id.lngText);
LocationManager myManager = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
Double latPoint =
myManager.getCurrentLocation("gps").getLatitude()*1E6;
Double lngPoint =
myManager.getCurrentLocation("gps").getLongitude()*1E6;
latText.setText(latPoint.toString());
lngText.setText(lngPoint.toString());
MapView myMap = (MapView) findViewById(R.id.myMap);
Point myLocation = new Point(latPoint.intValue(),lngPoint.intValue());
MapController myMapController = myMap.getController();
myMapController.centerMapTo(myLocation, false);
myMapController.zoomTo(9);
}
}
在模擬器中運行活動(dòng)?;顒?dòng)應當打開(kāi)一個(gè)空白的地圖。點(diǎn)擊“Where Am I”按鈕,應當會(huì )看到地圖聚焦并且放大到舊金山??纯聪聢D就會(huì )知道地圖會(huì )如何出現(略)。
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
Android之解決底部4個(gè)TextView占比例大小不一致問(wèn)題
Eclipse開(kāi)發(fā)Google Android應用程序教程(一)
Android輕松搞定流動(dòng)布局FlexboxLayout
TextView中多行字的行間距
Android 設置TextView滑動(dòng)滾動(dòng)條和滑動(dòng)效果
listview怎樣設置每個(gè)Item的高度?
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久