編輯:關於Android編程
廢話不多說了,直接給大家上干貨了。
以下為初次接觸時 ,練手的DEMO
import android.app.Activity; import android.app.ProgressDialog; import android.content.ContentValues; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.graphics.Color; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.text.Editable; import android.text.TextWatcher; import android.util.Log; import android.view.Gravity; import android.view.KeyEvent; import android.view.View; import android.widget.AdapterView; import android.widget.AutoCompleteTextView; import android.widget.Button; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.SimpleAdapter; import android.widget.TextView; import android.widget.Toast; import com.amap.api.location.AMapLocation; import com.amap.api.location.AMapLocationClient; import com.amap.api.location.AMapLocationClientOption; import com.amap.api.location.AMapLocationListener; import com.amap.api.maps.AMap; import com.amap.api.maps.CameraUpdateFactory; import com.amap.api.maps.LocationSource; import com.amap.api.maps.MapView; import com.amap.api.maps.UiSettings; import com.amap.api.maps.model.BitmapDescriptorFactory; import com.amap.api.maps.model.LatLng; import com.amap.api.maps.model.Marker; import com.amap.api.maps.model.MarkerOptions; import com.amap.api.maps.model.Poi; import com.amap.api.maps.overlay.PoiOverlay; import com.amap.api.services.core.LatLonPoint; import com.amap.api.services.core.PoiItem; import com.amap.api.services.core.SuggestionCity; import com.amap.api.services.geocoder.GeocodeQuery; import com.amap.api.services.geocoder.GeocodeResult; import com.amap.api.services.geocoder.GeocodeSearch; import com.amap.api.services.geocoder.RegeocodeQuery; import com.amap.api.services.geocoder.RegeocodeResult; import com.amap.api.services.help.Inputtips; import com.amap.api.services.help.InputtipsQuery; import com.amap.api.services.help.Tip; import com.amap.api.services.poisearch.PoiResult; import com.amap.api.services.poisearch.PoiSearch; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class BaseMapActivity extends Activity implements View.OnClickListener,LocationSource,AMapLocationListener,TextWatcher,Inputtips.InputtipsLi stener,AMap.OnMarkerClickListener,PoiSearch.OnPoiSearchListener,AMap.OnPOIClickListener,Ge ocodeSearch.OnGeocodeSearchListener{ private MapView mapView; private AMap aMap; private LinearLayout ly_1; private Button bt_map; private AutoCompleteTextView search_keyword; //輸入要搜索的keyword private ListView listview; //keyword 監聽數據形成的列表 private ProgressDialog progDialog = null;// 進度條顯示 private LinearLayout ly_2; //ly_1 所包含的布局之一 private Button bt_back1; private ListView history_listview; private TextView history_item_tv; List<Map<String, Object>> listItem; //輸入keyword,數據返回的list數據源 //====================以下為操作數據庫================== private ArrayList<HashMap<String, Object>> MapHistoryList; //=============地圖定位控件============== private OnLocationChangedListener mListener; private AMapLocationClient mlocationClient; private AMapLocationClientOption mLocationOption; //=============地圖自身UI定義============ private UiSettings mUiSettings; //=============通用地圖控件============== private LatLonPoint mLatLonPoint;//初始定位經緯度 private double ms,me; //經緯度double值 private String locationAdressName; //=============地圖POI關鍵字搜索========== private PoiResult poiResult; // poi返回的結果 private PoiSearch.Query query;// Poi查詢條件類 private PoiSearch poiSearch;// POI搜索 private static String keyWord = "";// 要輸入的poi搜索關鍵字 private int currentPage = 0;// 當前頁面,從0開始計數 private Button bt_search; //搜索POI private MarkerOptions options; //========================以下為地理編碼================= private GeocodeSearch geocoderSearch; private static String addressCityDistric; //得到逆地理編碼的 市區 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.base_map_activity); mapView = (MapView) findViewById(R.id.map); mapView.onCreate(savedInstanceState);// 此方法必須重寫 init(); initUi(); initHistoryList(); } /** * 初始化AMap對象 */ private void init() { if (aMap == null) { aMap = mapView.getMap(); setUpMap(); } } /** * 設置一些amap的屬性 */ private void setUpMap() { aMap.setLocationSource(this);// 設置定位監聽 aMap.getUiSettings().setMyLocationButtonEnabled(true);// 設置默認定位按鈕是否顯示 aMap.setMyLocationEnabled(true);// 設置為true表示顯示定位層並可觸發定位,false表示 隱藏定位層並不可觸發定位,默認是false // 設置定位的類型為定位模式 ,可以由定位、跟隨或地圖根據面向方向旋轉幾種 aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE); aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(me,ms), 14)); //當前 地圖鏡頭界面 (讓地圖在剛進入時就是這個的話,需要先得到LatLng值即可,待後續修正) mUiSettings= aMap.getUiSettings(); //實例化地圖UI設置 mUiSettings.setScaleControlsEnabled(true); //比例尺顯示 mUiSettings.setCompassEnabled(false); //指南針不顯示 mLocationOption.setGpsFirst(true); //優先返回GPS定位信息 aMap.setOnPOIClickListener(this); //POI 點擊事件監聽 aMap.setOnMarkerClickListener(this); geocoderSearch = new GeocodeSearch(this); geocoderSearch.setOnGeocodeSearchListener(this); // 注冊地理編碼監聽 } private void initUi(){ ly_1=(LinearLayout)findViewById(R.id.map_2); //地圖隱藏掉顯示的界面 bt_map=(Button)findViewById(R.id.map_bt); //首頁 按鈕 bt_map.setOnClickListener(this); //返回鍵 bt_back1=(Button)findViewById(R.id.bt_back_1); bt_back1.setOnClickListener(this); //keyword search_keyword=(AutoCompleteTextView)findViewById(R.id.keyWord); search_keyword.addTextChangedListener(this); //keyword輸入list listview=(ListView)findViewById(R.id.map_list); //第二頁顯示 ly_2=(LinearLayout)findViewById(R.id.history_record); //POI 搜索 按鈕 bt_search=(Button)findViewById(R.id.bt_search); bt_search.setOnClickListener(this); //歷史記錄 list history_listview=(ListView)findViewById(R.id.lv_history); history_item_tv=(TextView)findViewById(R.id.history_item_addressName); } @Override public void onClick(View v) { switch (v.getId()){ case R.id.map_bt: bt_map.setVisibility(View.GONE); mapView.setVisibility(View.GONE); ly_1.setVisibility(View.VISIBLE); break; case R.id.bt_search: // mlocationClient.stopLocation(); searchButton(); bt_map.setVisibility(View.GONE); mapView.setVisibility(View.VISIBLE); ly_1.setVisibility(View.VISIBLE); listview.setVisibility(View.GONE); ly_2.setVisibility(View.GONE); break; case R.id.bt_back_1: aMap.clear(); bt_map.setVisibility(View.VISIBLE); mapView.setVisibility(View.VISIBLE); ly_1.setVisibility(View.GONE); break; } } /** * 方法必須重寫 */ @Override protected void onResume() { super.onResume(); mapView.onResume(); } /** * 方法必須重寫 */ @Override protected void onPause() { super.onPause(); mapView.onPause(); } /** * 方法必須重寫 */ @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); mapView.onSaveInstanceState(outState); } /** * 方法必須重寫 */ @Override protected void onDestroy() { super.onDestroy(); mapView.onDestroy(); } /** * back設置 * @param keyCode * @param event * @return */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK ) { aMap.clear(); bt_map.setVisibility(View.VISIBLE); mapView.setVisibility(View.VISIBLE); ly_1.setVisibility(View.GONE); } return false; } //========================================================以下為定位 =============================================== /** * 激活定位 */ @Override public void activate(OnLocationChangedListener listener) { mListener = listener; if (mlocationClient == null) { mlocationClient = new AMapLocationClient(this); mLocationOption = new AMapLocationClientOption(); //設置定位監聽 mlocationClient.setLocationListener(this); //設置為高精度定位模式 mLocationOption.setLocationMode (AMapLocationClientOption.AMapLocationMode.Hight_Accuracy); //設置定位參數 mlocationClient.setLocationOption(mLocationOption); // 此方法為每隔固定時間會發起一次定位請求,為了減少電量消耗或網絡流量消耗, // 注意設置合適的定位時間的間隔(最小間隔支持為2000ms),並且在合適時間調用 stopLocation()方法來取消定位請求 // 在定位結束後,在合適的生命周期調用onDestroy()方法 // 在單次定位情況下,定位無論成功與否,都無需調用stopLocation()方法移除請求, 定位sdk內部會移除 mlocationClient.startLocation(); } } /** * 停止定位 */ @Override public void deactivate() { mListener = null; if (mlocationClient != null) { mlocationClient.stopLocation(); mlocationClient.onDestroy(); } mlocationClient = null; } /** * 定位成功後回調函數 */ @Override public void onLocationChanged(AMapLocation amapLocation) { if (mListener != null && amapLocation != null) { if (amapLocation != null && amapLocation.getErrorCode() == 0) { mListener.onLocationChanged(amapLocation);// 顯示系統小藍點 Message msg = mHandler.obtainMessage(); //定位成功後,開始hangler更新經緯 度 msg.obj = amapLocation; msg.what = Utils.MSG_LOCATION_FINISH; mHandler.sendMessage(msg); //當前定位後的詳細位置(省、市、區、街道信息) locationAdressName=amapLocation.getProvider()+amapLocation.getCity ()+amapLocation.getDistrict()+amapLocation.getAddress(); } else { String errText = "定位失敗," + amapLocation.getErrorCode()+ ": " + amapLocation.getErrorInfo(); Toast.makeText(getApplicationContext(),errText,Toast.LENGTH_SHORT).show(); } } } Handler mHandler = new Handler() { public void dispatchMessage(android.os.Message msg) { switch (msg.what) { //開始定位 case Utils.MSG_LOCATION_START: //("正在定位..."); break; // 定位完成 case Utils.MSG_LOCATION_FINISH: AMapLocation loc = (AMapLocation) msg.obj; String result = Utils.getLocationStr(loc); // (result); ms=Utils.jingdu; me=Utils.weidu; mLatLonPoint=new LatLonPoint(me,ms); break; //停止定位 case Utils.MSG_LOCATION_STOP: // ("定位停止"); break; default: break; } }; }; //=========================================以下為keyword 改變監聽 =================================== @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence s, int start, int stop, int count) { String newText = s.toString().trim(); //在這裡判斷 是否有輸入 if(s.length()<1){ ly_2.setVisibility(View.VISIBLE); listview.setVisibility(View.GONE); }else { ly_2.setVisibility(View.GONE); mapView.setVisibility(View.GONE); listview.setVisibility(View.VISIBLE); } if (!AMapUtil.IsEmptyOrNullString(newText)) { InputtipsQuery inputquery = new InputtipsQuery(newText, Utils.city); Inputtips inputTips = new Inputtips(BaseMapActivity.this, inputquery); inputTips.setInputtipsListener(this); //設置=======得到數據監聽======= inputTips.requestInputtipsAsyn(); } } @Override public void afterTextChanged(Editable editable) { } //=======得到數據監聽======= @Override public void onGetInputtips(List<Tip> tipList, int rCode) { if (rCode == 1000) {// 正確返回 //監聽反饋回來的數據當做listView數據源 listItem=new ArrayList<Map<String,Object>>(); for (int i = 0; i < tipList.size(); i++) { HashMap<String, Object> map = new HashMap<String, Object>(); map.put("mapName",tipList.get(i).getName()); map.put("mapAddress",tipList.get(i).getDistrict()); map.put("mapPosition",tipList.get(i).getPoint()); listItem.add(map); } listview.setAdapter(new MapListAdapter(this,listItem)); //輸入時keyword 產生的列表的 item點擊事件 listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { aMap.clear(); mlocationClient.stopLocation(); LatLonPoint latLonPoint=(LatLonPoint)(listItem.get(i).get ("mapPosition")); Double dd=latLonPoint.getLatitude(); Double ee=latLonPoint.getLongitude(); options=new MarkerOptions(); Marker marker=aMap.addMarker(options.position(new LatLng(dd,ee))); // 做marker標記 marker.setVisible(true); aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(dd,ee), 14));//移動視圖 bt_map.setVisibility(View.GONE); mapView.setVisibility(View.VISIBLE); ly_1.setVisibility(View.VISIBLE); listview.setVisibility(View.GONE); ly_2.setVisibility(View.GONE); Toast.makeText(getApplicationContext(),""+listItem.get(i).get ("mapPosition"),Toast.LENGTH_SHORT).show(); } }); } else { ToastUtil.showerror(this, rCode); } } //==========================================以下為POI關鍵字搜索 ===================================================== /** * 顯示進度框 */ private void showProgressDialog() { if (progDialog == null) progDialog = new ProgressDialog(this); progDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progDialog.setIndeterminate(false); progDialog.setCancelable(false); progDialog.setMessage("正在搜索:\n" + keyWord); progDialog.show(); } /** * 隱藏進度框 */ private void dissmissProgressDialog() { if (progDialog != null) { progDialog.dismiss(); } } /** * 點擊搜索按鈕 */ public void searchButton() { keyWord = AMapUtil.checkEditText(search_keyword); if ("".equals(keyWord)) { ToastUtil.show(BaseMapActivity.this, "請輸入搜索關鍵字"); return; } else { doSearchQuery(); if (MapHistoryList.size()>0){ for (int i=0;i<MapHistoryList.size();i++){ if (keyWord.equals(MapHistoryList.get(i).get("mapHistoryName").toString ())){ return; } }} map_addToHistory(); //增加數據到數據庫 } } /** * 開始進行poi搜索 */ protected void doSearchQuery() { showProgressDialog();// 顯示進度框 mlocationClient.stopLocation(); //停止定位 20160812 query = new PoiSearch.Query(keyWord, "", Utils.city);// 第一個參數表示搜索字符串第二個參數表示poi搜索類型,第三個參數表示poi搜索區域(空字符串代表全國) query.setPageSize(20);// 設置每頁最多返回多少條poiitem query.setPageNum(currentPage);// 設置查第一頁 poiSearch = new PoiSearch(this, query); poiSearch.setOnPoiSearchListener(this); poiSearch.searchPOIAsyn(); } /** * poi沒有搜索到數據,返回一些推薦城市的信息 */ private void showSuggestCity(List<SuggestionCity> cities) { String infomation = "推薦城市\n"; for (int i = 0; i < cities.size(); i++) { infomation += "城市名稱:" + cities.get(i).getCityName() + "城市區號:" + cities.get(i).getCityCode() + "城市編碼:" + cities.get(i).getAdCode() + "\n"; } ToastUtil.show(BaseMapActivity.this, infomation); } /** * POI信息查詢回調方法 */ @Override public void onPoiSearched(PoiResult result, int rCode) { dissmissProgressDialog();// 隱藏對話框 if (rCode == 1000) { if (result != null && result.getQuery() != null) {// 搜索poi的結果 if (result.getQuery().equals(query)) {// 是否是同一條 poiResult = result; // 取得搜索到的poiitems有多少頁 List<PoiItem> poiItems = poiResult.getPois();// 取得第一頁的poiitem數據,頁數從數字0開始 List<SuggestionCity> suggestionCities = poiResult .getSearchSuggestionCitys();// 當搜索不到poiitem數據時,會返回含有搜索關鍵字的城市信息 if (poiItems != null && poiItems.size() > 0) { aMap.clear();// 清理之前的圖標 PoiOverlay poiOverlay = new PoiOverlay(aMap, poiItems); poiOverlay.removeFromMap(); poiOverlay.addToMap(); poiOverlay.zoomToSpan(); } else if (suggestionCities != null && suggestionCities.size() > 0) { showSuggestCity(suggestionCities); } else { ToastUtil.show(BaseMapActivity.this, "無返回結果"); } } } else { ToastUtil.show(BaseMapActivity.this, "無返回結果"); } } else { ToastUtil.showerror(this, rCode); } } @Override public void onPoiItemSearched(PoiItem poiItem, int i) { } //===================以下為POI 點擊事件================ @Override public void onPOIClick(Poi poi) { // aMap.clear(); //暫時去掉 MarkerOptions markOptiopns = new MarkerOptions(); markOptiopns.position(poi.getCoordinate()); TextView textView = new TextView(getApplicationContext()); textView.setText("到"+poi.getName()+"去"); textView.setGravity(Gravity.CENTER); textView.setTextColor(Color.BLACK); textView.setBackgroundResource(R.drawable.dir1); markOptiopns.icon(BitmapDescriptorFactory.fromView(textView)); markOptiopns.icon(BitmapDescriptorFactory.defaultMarker()); aMap.addMarker(markOptiopns); LatLng newLatLng=poi.getCoordinate(); Double ss=newLatLng.latitude; Double se=newLatLng.longitude; // LatLonPoint newLatLonPoint=new LatLonPoint(ss,se); getAddress(new LatLonPoint(ss,se)); // Toast.makeText(getApplicationContext (),"marker"+addressCityDistric,Toast.LENGTH_SHORT).show(); } //==================以下為 marker 點擊事件反饋=================== @Override public boolean onMarkerClick(Marker marker) { Toast.makeText(getApplicationContext(),"marker點擊"+marker.getPosition ()+"--"+marker.getTitle()+"--"+marker.getSnippet(),Toast.LENGTH_SHORT).show(); marker.getPosition(); return false; } //========================以下為地理編碼以及你地理編碼================================ /** * 響應地理編碼 */ public void getLatlon(final String name) { // showDialog(); GeocodeQuery query = new GeocodeQuery(name, Utils.city);// 第一個參數表示地址,第 二個參數表示查詢城市,中文或者中文全拼,citycode、adcode, geocoderSearch.getFromLocationNameAsyn(query);// 設置同步地理編碼請求 } /** * 響應逆地理編碼 */ public void getAddress(final LatLonPoint latLonPoint) { // showDialog(); RegeocodeQuery query = new RegeocodeQuery(latLonPoint, 200, GeocodeSearch.AMAP);// 第一個參數表示一個Latlng,第二參數表示范圍多少米, 第三個參數表示是火系坐標系還是GPS原生坐標系 geocoderSearch.getFromLocationAsyn(query);// 設置同步逆地理編碼請求 } /** * 地理編碼查詢回調 */ @Override public void onGeocodeSearched(GeocodeResult result, int rCode) { // dismissDialog(); if (rCode == 1000) { if (result != null && result.getGeocodeAddressList() != null && result.getGeocodeAddressList().size() > 0) { // GeocodeAddress address = result.getGeocodeAddressList().get(0); // aMap.animateCamera(CameraUpdateFactory.newLatLngZoom( // AMapUtil.convertToLatLng(address.getLatLonPoint()), 15)); // geoMarker.setPosition(AMapUtil.convertToLatLng(address // .getLatLonPoint())); // addressName = "經緯度值:" + address.getLatLonPoint() + "\n位置描 述:" // + address.getFormatAddress(); } } else { ToastUtil.showerror(this, rCode); } } /** * 逆地理編碼回調 */ @Override public void onRegeocodeSearched(RegeocodeResult result, int rCode) { // dismissDialog(); if (rCode == 1000) { if (result != null && result.getRegeocodeAddress() != null) { addressCityDistric = result.getRegeocodeAddress().getFormatAddress(); TextView tv=(TextView)findViewById(R.id.address_name); tv.setText(addressCityDistric); Log.e("fans",""+addressCityDistric); } else { ToastUtil.showerror(this, rCode); } } } } 資源文件如下: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.gaodemap.BaseMapActivity"> <Button android:id="@+id/map_bt" android:layout_width="260dp" android:layout_height="40dp" android:text="|查地點、搜路線" android:layout_marginLeft="10dp" android:layout_marginTop="7dp" android:background="@android:color/white" /> <com.amap.api.maps.MapView android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" > </com.amap.api.maps.MapView> <LinearLayout android:id="@+id/ly_address_route" android:layout_width="350dp" android:layout_height="70dp" android:orientation="vertical" android:layout_centerHorizontal="true" android:layout_marginTop="450dp" android:background="@android:color/darker_gray" > <LinearLayout android:layout_width="match_parent" android:layout_height="40dp" android:orientation="horizontal" > <TextView android:id="@+id/address_name" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center"/> <TextView android:id="@+id/xiangqing" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="3" android:text="詳情" android:gravity="center" /> </LinearLayout> <FrameLayout android:layout_width="match_parent" android:layout_height="1dp" android:background="@android:color/black"></FrameLayout> <TextView android:id="@+id/route_tv" android:layout_width="match_parent" android:layout_height="29dp" android:text="路徑規劃" android:gravity="center"/> </LinearLayout> <LinearLayout android:id="@+id/map_2" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:visibility="gone"> <LinearLayout android:layout_width="match_parent" android:layout_height="60dp" android:orientation="horizontal"> <Button android:id="@+id/bt_back_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="返回"/> <AutoCompleteTextView android:id="@+id/keyWord" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="請輸入關鍵字" android:textSize="14dp" android:imeOptions="actionDone" android:inputType="text|textAutoComplete" android:maxLength="20" android:layout_weight="2"/> <Button android:id="@+id/bt_search" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="搜索"/> </LinearLayout> <ListView android:id="@+id/map_list" android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone"></ListView> <LinearLayout android:id="@+id/history_record" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="@android:color/darker_gray" > <TextView android:id="@+id/history_tv" android:layout_width="match_parent" android:layout_height="50dp" android:text="歷史記錄" android:textSize="16dp" android:gravity="center" /> <ListView android:id="@+id/lv_history" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp"></ListView> <TextView android:id="@+id/zero_history_tv" android:layout_width="match_parent" android:layout_height="50dp" android:text="清空歷史記錄" android:textSize="16dp" android:gravity="center" /> </LinearLayout> </LinearLayout> </RelativeLayout> 代碼中相關的工具類,即官方DEMO 中提供的工具類,並沒什麼改變。。 好了,初步的使用就是這樣。 清單文件中相關權限 <!--地圖相關權限--> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_CONFIGURATION" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WRITE_SETTINGS" /> <!-- 定位需要的服務 使用2.0的定位需要加上這個 --> <service android:name="com.amap.api.location.APSService" ></service> 申請官方相關key ,根據自己androdi studio 上的sha1值和包名來獲取 <meta-data android:name="com.amap.api.v2.apikey" android:value="xxxxxxxxxxxxxxxxxxxxxxx" />
以上所述是小編給大家介紹的關於Android高德地圖的簡單開發實例代碼(DEMO),希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對本站網站的支持!
本文實例講述了Android實現九宮格(GridView中各項平分空間)的方法。分享給大家供大家參考。具體如下:項目需要做一個九宮格(也不一定是9的,4宮格、16宮格、4
Android的設置界面實現比較簡單,有時甚至只需要使用一個簡單的xml文件即可.聲明簡單,但是如何從PreferenceScreen或者PreferenceCatego
當前比較成熟一點的應用基本上都會在進入應用之顯示一個啟動界面.這個啟動界面或簡單,或復雜,或簡陋,或華麗,用意不同,風格也不同.下面來觀摩幾個流行的應用的啟動界面.1.
在我們開發APP時不僅要在代碼實現上,做到對App的優化,而在我們的界面布局也有許多要優化的地方,如果布局寫的很low的話,系統加載布局的速度會十分的慢,使得用戶的體驗非