百度地圖實現拖動圖標輸入地址

一,Activity代碼

public class SaasLocationActivity extends BaseActivity
		implements OnGetGeoCoderResultListener, OnGetPoiSearchResultListener, View.OnClickListener {
	private static String TAG = SaasLocationActivity.class.getSimpleName();
	private ListView near_address_list;
	private ListView search_address_list_view_end;
	private ListView search_address_list_view_start;
	private TextView search_empty_tv;

	private ClearEditText ce_search_start;
	private ClearEditText ce_search_end;

	private LinearLayout search_ll;
	private LinearLayout near_list_empty_ll;
	private LinearLayout ll_map;
	// private LinearLayout ll_loadlayer;
	private LinearLayout near_address_ll;

	private ImageButton ib_home_arrow;
	private CheckBox cb_current_traffic;
	private CheckBox cb_weixingtu;
	private ImageView iv_back;

	private MapView mMapView = null;
	private BaiduMap mBaiduMap = null;

	private GeoCoder mSearch = null; // 搜索模塊,也可去掉地圖模塊獨立使用
	private MyLocationListenner myListener;
	private LocationClient mLocClient;// 定位相關
	private LocationMode mCurrentMode;
	private boolean isFirstLoc = true;// 是否首次定位
	private PoiSearch mPoiSearch = null;
	private String cityName;
	private boolean EDIT_FOCUS=true;// 判斷焦點所在位置
	private boolean SEARCH_FLAG = true;
	private boolean NEAR_FLAG = true;

	private NearAddressAdapter nearAddressAdapter = null;
	private SearchAddressAdapter searchAddressAdapter = null;
	private List<PoiInfo> nearAddresses = new ArrayList<PoiInfo>();
	private List<PoiInfo> searchAddresses = new ArrayList<PoiInfo>();
	private String start_address;
	private String end_address;
	private String start_address_detail;
	private String end_address_detail;
	private LatLng startLatLng;
	private LatLng endLatLng;

	public static final int EDIT_FOCUS_START = 1;
	public static final int EDIT_FOCUS_END = 2;
	private Handler handle = new Handler() {
		public void handleMessage(android.os.Message msg) {
			switch (msg.what) {
			case EDIT_FOCUS_START:
				EDIT_FOCUS = true;
				Toast.makeText(SaasLocationActivity.this, "切換地圖模式", Toast.LENGTH_SHORT).show();
				mBaiduMap.setMapType(BaiduMap.MAP_TYPE_SATELLITE);
				break;
			case EDIT_FOCUS_END:
				EDIT_FOCUS = false;
				break;
			}
		}
	};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		MyApplication.getInstance().addActivity(this);
		LatLng defaultLatLng = new LatLng(22.555133, 114.066218);
		mMapView = new MapView(this,
				new BaiduMapOptions().mapStatus(new MapStatus.Builder().target(defaultLatLng).zoom(16).build())
						.scaleControlEnabled(true).zoomControlsEnabled(false));
		setContentView(R.layout.activity_saas_location);
		initViews();
		setFocus();
		initViewsAndEvents();
	}

	public void setFocus() {
		OnFocusChangeListener mFocusChangedListener;
		mFocusChangedListener = new OnFocusChangeListener() {
			@Override
			public void onFocusChange(View v, boolean hasFocus) {
				if (hasFocus) {
					EDIT_FOCUS = true;
					LogUtil.i(TAG, "起點輸入框獲得光標");
				} else {
					LogUtil.i(TAG, "終點輸入框獲得光標");
					EDIT_FOCUS = false;
				}
			}

		};

		ce_search_start.setOnFocusChangeListener(mFocusChangedListener);
	}

	// 初始化控件
	private void initViews() {
		near_list_empty_ll = (LinearLayout) findViewById(R.id.near_list_empty_ll);
		near_address_list = (ListView) findViewById(R.id.near_address_list);
		search_address_list_view_end = (ListView) findViewById(R.id.search_address_list_view_end);
		search_address_list_view_start = (ListView) findViewById(R.id.search_address_list_view_start);
		ce_search_start = (ClearEditText) findViewById(R.id.ce_search_start);
		ce_search_end = (ClearEditText) findViewById(R.id.ce_search_end);
		search_empty_tv = (TextView) findViewById(R.id.search_empty_tv);
		search_ll = (LinearLayout) findViewById(R.id.search_ll);
		// ll_loadlayer = (LinearLayout) findViewById(R.id.ll_loadlayer);
		ib_home_arrow = (ImageButton) findViewById(R.id.ib_home_arrow);
		cb_current_traffic = (CheckBox) findViewById(R.id.cb_current_traffic);
		cb_weixingtu = (CheckBox) findViewById(R.id.cb_weixingtu);
		iv_back = (ImageView) findViewById(R.id.iv_back);

		myListener = new MyLocationListenner();

		near_address_ll = (LinearLayout) findViewById(R.id.near_address_ll);
		ll_map = (LinearLayout) findViewById(R.id.ll_map);
		ll_map.addView(mMapView);
		mBaiduMap = mMapView.getMap();

	}

	// 初始化地圖
	protected void initViewsAndEvents() {
		cityName = "深圳";// 這個可以通過定位獲取
		// 隱藏比例尺和縮放圖標
		mMapView.showScaleControl(false);
		mMapView.showZoomControls(false);
		mBaiduMap = mMapView.getMap();
		mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);

		// 初始化搜索模塊,註冊事件監聽
		mSearch = GeoCoder.newInstance();
		// 初始化搜索模塊,註冊搜索事件監聽
		mPoiSearch = PoiSearch.newInstance();
		mPoiSearch.setOnGetPoiSearchResultListener(this);
		mSearch.setOnGetGeoCodeResultListener(this);
		ib_home_arrow.setOnClickListener(this);
		cb_current_traffic.setOnClickListener(this);
		cb_weixingtu.setOnClickListener(this);
		iv_back.setOnClickListener(this);
		// 監聽地圖狀態,若地圖發生改變,重新獲取地圖中心位置

		mBaiduMap.setOnMapStatusChangeListener(new OnMapStatusChangeListener() {

			@Override
			public void onMapStatusChangeStart(MapStatus arg0) {

			}

			@Override
			public void onMapStatusChangeFinish(MapStatus arg0) {
				search_ll.setVisibility(View.GONE);
				mBaiduMap.clear();
				// 反Geo搜索,arg0則爲新的中心
				mSearch.reverseGeoCode(new ReverseGeoCodeOption().location(arg0.target));

			}

			@Override
			public void onMapStatusChange(MapStatus arg0) {

			}
		});
		if (EDIT_FOCUS) {
			ce_search_start.addTextChangedListener(new TextWatcher() {

				@Override
				public void onTextChanged(CharSequence s, int start, int before, int count) {
					// search_address_list_view_start.setVisibility(View.VISIBLE);
					// search_address_list_view_end.setVisibility(View.GONE);
					Log.i("info2", "輸入框信息:" + s + "----->城市:" + cityName);
					if (s == null || s.length() <= 0) {
						search_ll.setVisibility(View.GONE);
						return;
					}
					if (NEAR_FLAG) {
						near_address_list.setVisibility(View.GONE);
					}

					/**
					 * 使用建議搜索服務獲取建議列表
					 */

					mPoiSearch.searchInCity((new PoiCitySearchOption()).city(cityName).keyword(s.toString()).pageNum(0)
							.pageCapacity(20));

				}

				@Override
				public void beforeTextChanged(CharSequence s, int start, int count, int after) {
					Log.i("info1", "輸入框信息:" + s + "------->城市:" + cityName);

				}

				@Override
				public void afterTextChanged(Editable s) {
					Log.i("info3", "輸入框信息:" + s + "-------->城市:" + cityName);
				}
			});

		} else {

			ce_search_end.addTextChangedListener(new TextWatcher() {

				@Override
				public void onTextChanged(CharSequence s, int start, int before, int count) {
					// search_address_list_view_start.setVisibility(View.GONE);
					// search_address_list_view_end.setVisibility(View.VISIBLE);
					Log.i("info22", "輸入框信息:" + s + "----->城市:" + cityName);
					if (s == null || s.length() <= 0) {
						search_ll.setVisibility(View.GONE);
						return;
					}
					if (SEARCH_FLAG) {
						search_address_list_view_end.setVisibility(View.GONE);
					}
					/**
					 * 使用建議搜索服務獲取建議列表
					 */

					mPoiSearch.searchInCity((new PoiCitySearchOption()).city(cityName).keyword(s.toString()).pageNum(0)
							.pageCapacity(20));

				}

				@Override
				public void beforeTextChanged(CharSequence s, int start, int count, int after) {
					Log.i("info12", "輸入框信息:" + s + "------->城市:" + cityName);

				}

				@Override
				public void afterTextChanged(Editable s) {
					Log.i("info33", "輸入框信息:" + s + "-------->城市:" + cityName);
				}
			});
		}

		mCurrentMode = LocationMode.Hight_Accuracy;
		// 開啓定位圖層
		mBaiduMap.setMyLocationEnabled(false);

		// 定位初始化
		mLocClient = new LocationClient(this);
		// 設置地圖縮放級別爲15
		mBaiduMap.setMapStatus(MapStatusUpdateFactory.newMapStatus(new MapStatus.Builder().zoom(15).build()));
		mLocClient.registerLocationListener(myListener);
		LocationClientOption option = new LocationClientOption();
		// 設置是否返回定位結果 包括地址信息
		option.setIsNeedAddress(true);
		// 設置返回結果是否包含手機機頭的方向
		option.setNeedDeviceDirect(true);
		option.setOpenGps(false);// 打開gpss
		option.setCoorType("bd09ll"); // 設置座標類型 取值有3個: 返回國測局經緯度座標系:gcj02
		// 返回百度墨卡託座標系 :bd09 返回百度經緯度座標系 :bd09ll
		option.setScanSpan(1000);// 掃描間隔 單位毫秒
		option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
		mLocClient.setLocOption(option);
		mLocClient.start();
		// mBaiduMap.setMapType(BaiduMap.MAP_TYPE_SATELLITE);
		mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
		nearAddressAdapter = new NearAddressAdapter(this, R.layout.item_near_address, nearAddresses);
		near_address_list.setAdapter(nearAddressAdapter);
		near_address_list.setEmptyView(near_list_empty_ll);

		near_address_list.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				PoiInfo poiInfo = nearAddresses.get(position);
				Bundle bundle = new Bundle();
				bundle.putString("Ing", poiInfo.location.longitude + "");
				bundle.putString("Iat", poiInfo.location.latitude + "");
				bundle.putString("Address", poiInfo.name);
				bundle.putString("DetailedAddress", poiInfo.address);
				//TODO 設置詳細地址
				start_address_detail=poiInfo.address;
				ce_search_start.setText(poiInfo.name);

				if (StringUtils.isEmpty(ce_search_start.getText().toString())) {
					NEAR_FLAG = false;
				} else {
					near_address_ll.setVisibility(View.GONE);
					NEAR_FLAG = true;
				}

				// Intent intent = new Intent();
				// intent.putExtras(bundle);
				// setResult(RESULT_OK, intent);
				// finish();
				// if(nearAddresses!=null && nearAddresses.size()>0){
				// poiInfo = nearAddresses.get(0);
				// String nearLoc=poiInfo.address;
				// ce_search_start.setText(nearLoc);
				// }
			}
		});

		searchAddressAdapter = new SearchAddressAdapter(this, R.layout.item_search_address, searchAddresses);
		if (EDIT_FOCUS) {
			// search_address_list_view_start.setVisibility(View.VISIBLE);
			// search_address_list_view_end.setVisibility(View.GONE);
			search_address_list_view_start.setAdapter(searchAddressAdapter);
			search_address_list_view_start.setEmptyView(search_empty_tv);
			search_address_list_view_start.setOnItemClickListener(new OnItemClickListener() {

				@Override
				public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
					PoiInfo poiInfo = searchAddresses.get(position);
					Bundle bundle = new Bundle();
					bundle.putString("Ing", poiInfo.location.longitude + "");
					bundle.putString("Iat", poiInfo.location.latitude + "");
					bundle.putString("Address", poiInfo.name);
					bundle.putString("DetailedAddress", poiInfo.address);
					ce_search_start.setText(poiInfo.name);
					if (StringUtils.isEmpty(ce_search_end.getText().toString())) {
						SEARCH_FLAG = false;
					} else {
						search_address_list_view_start.setVisibility(View.GONE);
						SEARCH_FLAG = true;
					}
					// Intent intent = new Intent();
					// intent.putExtras(bundle);
					// setResult(RESULT_OK, intent);
					// finish();
				}
			});
		} else {
			LogUtil.i(TAG, "終點輸入框獲得光標,開始顯示列表");
			// searchAddressAdapter = new SearchAddressAdapter(this,
			// R.layout.item_search_address, searchAddresses);
			// search_address_list_view_end.setVisibility(View.VISIBLE);
			// search_address_list_view_start.setVisibility(View.GONE);
			search_address_list_view_end.setAdapter(searchAddressAdapter);
			search_address_list_view_end.setEmptyView(search_empty_tv);

			search_address_list_view_end.setOnItemClickListener(new OnItemClickListener() {

				@Override
				public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
					PoiInfo poiInfo = searchAddresses.get(position);
					Bundle bundle = new Bundle();
					bundle.putString("Ing", poiInfo.location.longitude + "");
					bundle.putString("Iat", poiInfo.location.latitude + "");
					bundle.putString("Address", poiInfo.name);
					bundle.putString("DetailedAddress", poiInfo.address);
					//TODO 設置詳細地址
					end_address_detail=poiInfo.address;
					ce_search_end.setText(poiInfo.name);
					end_address = ce_search_end.getText().toString();
					endLatLng = new LatLng(poiInfo.location.latitude, poiInfo.location.longitude);
					if ((StringUtils.isNotEmpty(ce_search_start.getText().toString(), true))
							&& (StringUtils.isNotEmpty(ce_search_end.getText().toString(), true))) {
						Intent intent = new Intent(SaasLocationActivity.this, ConfirmOrderActivity.class);
						intent.putExtra("end_address", end_address);
						intent.putExtra("start_address", start_address);
						intent.putExtra("start_address_detail", start_address_detail);
						intent.putExtra("end_address_detail", end_address_detail);
						intent.putExtra("startLat", startLatLng.latitude);
						intent.putExtra("startLng", startLatLng.longitude);
						intent.putExtra("endLat", endLatLng.latitude);
						intent.putExtra("endLng", endLatLng.longitude);
						startActivity(intent);
						
					}
					// Intent intent = new Intent();
					// intent.putExtras(bundle);
					// setResult(RESULT_OK, intent);
					// finish();
					
				}
			});

		}
	}

	@Override
	protected void onPause() {
		mMapView.onPause();
		super.onPause();
	}

	@Override
	protected void onResume() {
		mMapView.onResume();
		super.onResume();
	}

	@Override
	protected void onDestroy() {
		mMapView.onDestroy();
		super.onDestroy();
		mSearch.destroy();
		// 退出時銷燬定位
		mLocClient.stop();
		// 關閉定位圖層
		// mBaiduMap.setMyLocationEnabled(false);
		MyApplication.getInstance().delActivityList(this);
		mMapView = null;
	}

	@Override
	public void onGetGeoCodeResult(GeoCodeResult arg0) {

	}

	// 通過中點的經緯度獲取到周圍的地點
	@Override
	public void onGetReverseGeoCodeResult(ReverseGeoCodeResult result) {
		if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
			Toast.makeText(SaasLocationActivity.this, "抱歉,未能找到結果", Toast.LENGTH_LONG).show();
			return;
		}

		List<PoiInfo> list = result.getPoiList();
		if (list != null && list.size() > 0) {
			nearAddresses.clear();
			nearAddresses.addAll(list);
			nearAddressAdapter.notifyDataSetChanged();
		}
		if(nearAddresses.size()>0){
			
			ce_search_start.setText(nearAddresses.get(0).name.toString());
			startLatLng = new LatLng(nearAddresses.get(0).location.latitude, nearAddresses.get(0).location.longitude);
			start_address = ce_search_start.getText().toString();
			start_address_detail=nearAddresses.get(0).address.toString();
			NEAR_FLAG = true;
		}


	}

	/**
	 * 定位SDK監聽函數
	 */

	public class MyLocationListenner implements BDLocationListener {

		@Override
		public void onReceiveLocation(BDLocation location) {
			// mapview 銷燬後不在處理新接收的位置
			if (location == null || mMapView == null) {
				return;
			}
			MyLocationData locData = new MyLocationData.Builder().accuracy(location.getRadius())
					// 此處設置開發者獲取到的方向信息,順時針0-360
					.latitude(location.getLatitude()).longitude(location.getLongitude()).build();
			mBaiduMap.setMyLocationData(locData);
			double Latitude = location.getLatitude(); // 獲取經度
			double Longitude = location.getLongitude(); // 獲取緯度
			String City = location.getCity();
			String CityID = location.getCityCode();
			String time = location.getTime();
			String address = location.getAddrStr();
			// Log.i("info", "經度:" + Longitude + "緯度:" + Latitude + "城市:" + City
			// + "地址:" + address + "時間:" + time);
			if (location.getCity() != null) {
				cityName = location.getCity();

			}

			if (isFirstLoc) {
				isFirstLoc = false;
				LatLng ll = new LatLng(location.getLatitude(), location.getLongitude());
				MapStatusUpdate mapStatusUpdate = MapStatusUpdateFactory.newLatLng(ll);
				mBaiduMap.animateMapStatus(mapStatusUpdate);
				// ll_loadlayer.setVisibility(View.GONE);
			}
		}

		public void onReceivePoi(BDLocation poiLocation) {
		}
	}

	@Override
	public void onGetPoiDetailResult(PoiDetailResult arg0) {

	}

	@Override
	public void onGetPoiResult(PoiResult result) {
		if (result == null || result.error == SearchResult.ERRORNO.RESULT_NOT_FOUND) {
			return;
		}
		if (result.error == SearchResult.ERRORNO.NO_ERROR) {
			List<PoiInfo> list = result.getAllPoi();
			search_ll.setVisibility(View.VISIBLE);
			if (list != null && list.size() > 0) {
				searchAddresses.clear();
				searchAddresses.addAll(list);
				searchAddressAdapter.notifyDataSetChanged();
			}
		}
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.ib_home_arrow:
			Toast.makeText(SaasLocationActivity.this, "正在定位中...", Toast.LENGTH_SHORT).show();
			isFirstLoc = true;
			break;
		case R.id.cb_current_traffic:

			if (mBaiduMap.isTrafficEnabled()) {
				// 開啓交通圖
				mBaiduMap.setTrafficEnabled(false);
			} else {
				mBaiduMap.setTrafficEnabled(true);
			}
			break;
		case R.id.cb_weixingtu:

			if (mBaiduMap.getMapType() == BaiduMap.MAP_TYPE_NORMAL) {
				// 衛星地圖
				mBaiduMap.setMapType(BaiduMap.MAP_TYPE_SATELLITE);
			} else if (mBaiduMap.getMapType() == BaiduMap.MAP_TYPE_SATELLITE) {
				// 普通地圖
				mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
			}
			break;
		case R.id.iv_back:
			finish();
			break;

		}

	}

二,xml佈局文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:saasuser="http://schemas.android.com/apk/res/com.small.saasuser.activity"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:orientation="vertical" >

    <include
        android:id="@+id/ll_loadlayer"
        layout="@layout/data_load" />

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <LinearLayout
            android:id="@+id/ll_map"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >
        </LinearLayout>

        <ImageView
            android:layout_width="20dp"
            android:layout_height="20dp"
            android:layout_gravity="center"
            android:src="@drawable/point" />

        <CheckBox
            android:id="@+id/cb_current_traffic"
            android:layout_width="35dp"
            android:layout_height="35dp"
            android:layout_above="@+id/cb_weixingtu"
            android:layout_marginLeft="300dp"
            android:layout_marginTop="250dp"
            android:background="@drawable/map_small_point_lukuang_selector"
            android:button="@null" />

        <CheckBox
            android:id="@+id/cb_weixingtu"
            android:layout_width="35dp"
            android:layout_height="35dp"
            android:layout_above="@+id/ib_home_arrow"
            android:layout_marginLeft="300dp"
            android:layout_marginTop="300dp"
            android:background="@drawable/map_small_point_weixing_selector"
            android:button="@null" />

        <ImageButton
            android:id="@+id/ib_home_arrow"
            android:layout_width="35dp"
            android:layout_height="35dp"
            android:layout_marginLeft="300dp"
            android:layout_marginTop="350dp"
            android:background="@drawable/map_small_point_home" />

        <LinearLayout
            android:id="@+id/ll_input"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#ffffff"
            android:orientation="vertical" >

            <com.small.saasuser.view.BaseTitleView
                android:id="@+id/title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                saasuser:saasusertitle="馬上用車" />

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp" >

                <ImageView
                    android:id="@+id/iv_start_ocation"
                    android:layout_width="30dp"
                    android:layout_height="30dp"
                    android:src="@drawable/location_start" />

                <ImageView
                    android:id="@+id/iv_flow"
                    android:layout_width="20dp"
                    android:layout_height="20dp"
                    android:layout_below="@+id/iv_start_ocation"
                    android:layout_marginLeft="5dp"
                    android:src="@drawable/flow" />

                <TextView
                    android:id="@+id/textView1"
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_below="@+id/rl_map_sousuo"
                    android:layout_marginLeft="17dp"
                    android:layout_marginRight="10dp"
                    android:layout_marginTop="10dp"
                    android:layout_toRightOf="@+id/iv_flow"
                    android:background="#999999" />

                <ImageView
                    android:id="@+id/iv_end_location"
                    android:layout_width="30dp"
                    android:layout_height="30dp"
                    android:layout_below="@+id/iv_flow"
                    android:src="@drawable/location_end" />

                <RelativeLayout
                    android:id="@+id/rl_map_sousuo"
                    android:layout_width="match_parent"
                    android:layout_height="30dp"
                    android:layout_marginLeft="5dp"
                    android:layout_marginRight="10dp"
                    android:layout_toRightOf="@+id/iv_start_ocation"
                    android:gravity="center_vertical" >

                    <com.small.saasuser.view.ClearEditText
                        android:id="@+id/ce_search_start"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_centerVertical="true"
                        android:layout_marginLeft="10dp"
                        android:layout_marginRight="2dp"
                        android:layout_marginTop="10dp"
                        android:background="@null"
                        android:focusable="true"
                        android:hint="請搜索您的小區或大廈、街道的名稱"
                        android:singleLine="true"
                        android:textColorHint="#eeeeee"
                        android:textSize="14sp" />
                </RelativeLayout>

                <RelativeLayout
                    android:id="@+id/rl_map_sousuo2"
                    android:layout_width="match_parent"
                    android:layout_height="40dp"
                    android:layout_alignTop="@+id/iv_end_location"
                    android:layout_marginLeft="5dp"
                    android:layout_marginRight="10dp"
                    android:layout_toRightOf="@+id/iv_end_location"
                    android:gravity="center_vertical" >

                    <com.small.saasuser.view.ClearEditText
                        android:id="@+id/ce_search_end"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_centerVertical="true"
                        android:layout_marginLeft="10dp"
                        android:layout_marginRight="2dp"
                        android:background="@null"
                        android:hint="請搜索您的小區或大廈、街道的名稱"
                        android:singleLine="true"
                        android:textColorHint="#eeeeee"
                        android:textSize="14sp" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_below="@+id/ce_search_end"
                        android:layout_marginLeft="5dp"
                        android:layout_marginTop="12dp"
                        android:background="#999999" />
                </RelativeLayout>
            </RelativeLayout>
        </LinearLayout>

        <LinearLayout
            android:id="@+id/near_address_ll"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="400dp"
            android:orientation="vertical" >

            <TextView
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:background="#f5f5f5"
                android:gravity="center_vertical"
                android:paddingLeft="10dp"
                android:text="附近地點"
                android:textSize="14sp" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" >

                <ListView
                    android:id="@+id/near_address_list"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="#f5f5f5" >
                </ListView>

                <LinearLayout
                    android:id="@+id/near_list_empty_ll"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:visibility="gone" >

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="80dp"
                        android:gravity="center"
                        android:text="附近暫時沒有任何地點信息"
                        android:textSize="14sp" />
                </LinearLayout>
            </LinearLayout>
        </LinearLayout>

        <LinearLayout
            android:id="@+id/search_ll"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="150dp"
            android:background="#f5f5f5"
            android:orientation="vertical" >

            <ListView
                android:id="@+id/search_address_list_view_start"
                android:layout_width="wrap_content"
                android:layout_height="200dp"
                android:layout_gravity="center_horizontal"
                android:background="#f5f5f5"
                android:visibility="gone" >
            </ListView>

            <ListView
                android:id="@+id/search_address_list_view_end"
                android:layout_width="wrap_content"
                android:layout_height="200dp"
                android:layout_gravity="center_horizontal"
                android:background="#f5f5f5"
                android:visibility="gone" >
            </ListView>

            <TextView
                android:id="@+id/search_empty_tv"
                android:layout_width="match_parent"
                android:layout_height="80dp"
                android:background="#eeeeee"
                android:gravity="center"
                android:text="沒有搜索到相關結果\n請您選擇用地圖標註您所在的位置"
                android:textColor="@color/white"
                android:textSize="14sp"
                android:visibility="gone" />
        </LinearLayout>
    </FrameLayout>
    <!--
    <include
        android:id="@+id/ll_loadlayer"
        android:visibility="gone"
        layout="@layout/data_load" />


    -->

</RelativeLayout>
三,記得在AndroidManifest.xml文件完成相關配置。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章