zoukankan      html  css  js  c++  java
  • QQ发送位置(高德地图)

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:background="#00b4ef"
            android:orientation="horizontal" >
    
            <ImageButton
                android:id="@+id/mapaddress_back"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="4"
                android:background="#00000000"
                android:src="@mipmap/left_back" />
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:layout_gravity="center_vertical"
                android:layout_weight="1.5"
                android:background="@drawable/fillet"
                android:orientation="horizontal" >
    
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_marginLeft="10dp"
                    android:src="@mipmap/seek" />
    
                <Button
                    android:id="@+id/mapaddress_search"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginLeft="10dp"
                    android:background="#00000000"
                    android:gravity="center_vertical"
                    android:hint="搜索小区/学校/大厦" />
            </LinearLayout>
    
            <Button
                android:id="@+id/sendlocation"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="3.5"
                android:background="#00000000"
                android:clickable="true"
                android:text="发送" />
        </LinearLayout>
    
        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1" >
    
            <com.amap.api.maps.MapView
                android:id="@+id/mapaddress_map"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1.5" >
            </com.amap.api.maps.MapView>
    
            <ImageButton
                android:id="@+id/mapaddress_centerpoint"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:background="#00000000"
                android:src="@mipmap/ingbig" />
        </FrameLayout>
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="vertical" >
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:padding="10dp" >
    
                <ImageView
                    android:layout_width="20dp"
                    android:layout_height="10dp"
                    android:layout_gravity="center_vertical"
                    android:src="@mipmap/gps" />
    
                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="8dp"
                    android:orientation="vertical" >
    
                    <TextView
                        android:id="@+id/mapaddress_name"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="请选择地址"
                        android:textColor="@android:color/holo_red_light"
                        android:textSize="18dp" />
    
                    <TextView
                        android:id="@+id/mapaddress_miaoshu"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text=""
                        android:textColor="@android:color/holo_red_light"
                        android:textSize="15dp" />
                </LinearLayout>
            </LinearLayout>
    
            <ListView
                android:id="@+id/addresslistview"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@android:color/white"
                android:dividerHeight="1dp" />
        </LinearLayout>
    
    </LinearLayout>
    mapview
    package com.changim.app.ui.chat;
    
    import java.io.FileOutputStream;
    import java.util.List;
    import com.amap.api.location.AMapLocation;
    import com.amap.api.location.AMapLocationClient;
    import com.amap.api.location.AMapLocationClientOption;
    import com.amap.api.location.AMapLocationClientOption.AMapLocationMode;
    import com.amap.api.location.AMapLocationListener;
    import com.amap.api.maps.AMap;
    import com.amap.api.maps.AMap.OnCameraChangeListener;
    import com.amap.api.maps.AMap.OnMapScreenShotListener;
    import com.amap.api.maps.CameraUpdateFactory;
    import com.amap.api.maps.LocationSource;
    import com.amap.api.maps.MapView;
    import com.amap.api.maps.model.CameraPosition;
    import com.amap.api.maps.model.LatLng;
    import com.amap.api.maps.model.MarkerOptions;
    import com.amap.api.services.core.LatLonPoint;
    import com.amap.api.services.core.PoiItem;
    import com.amap.api.services.poisearch.PoiResult;
    import com.amap.api.services.poisearch.PoiSearch;
    import com.amap.api.services.poisearch.PoiSearch.OnPoiSearchListener;
    import com.amap.api.services.poisearch.PoiSearch.SearchBound;
    import com.changim.app.R;
    
    import com.changim.app.ui.adapter.AddressAdapter;
    import android.app.Activity;
    import android.content.Intent;
    import android.graphics.Bitmap;
    import android.os.Bundle;
    import android.os.Environment;
    import android.util.Log;
    import android.view.KeyEvent;
    import android.view.View;
    import android.view.Window;
    import android.view.View.OnClickListener;
    import android.widget.AdapterView;
    import android.widget.Button;
    import android.widget.ImageButton;
    import android.widget.ListView;
    import android.widget.TextView;
    import android.widget.Toast;
    import android.widget.AdapterView.OnItemClickListener;
    
    public class MapAddress extends Activity implements LocationSource, OnCameraChangeListener, AMapLocationListener, OnPoiSearchListener,OnClickListener,OnMapScreenShotListener {
    
        public  AMap aMap;//地图对象
        private MapView mapView;//地图控件
        private OnLocationChangedListener mListener;//位置移动监听
        private AMapLocationClient mlocationClient;
        private AMapLocationClientOption mLocationOption;
        private static MarkerOptions markerOption;//地图标记设置项
    
        private PoiSearch poiSearch;//关键字搜索
        private List<PoiItem> list;//存放位置信息
        private ListView addresslistview;//地址选择列表
        private double longitude,latitude;//经度,维度;
        ImageButton back;
        Button search;//关键字搜索按钮
        TextView name,miaoshu;//地点名称 位置描述
        Button sendlocation;//分享位置按钮
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
            setContentView(R.layout.mapview);
            info();
            mapView.onCreate(savedInstanceState); // 此方法必须重写
    
            init();
            addresslistview.setOnItemClickListener(new OnItemClickListener() {
    
                @Override
                public void onItemClick(AdapterView<?> parent, View view,
                                        int position, long id) {
                    name.setText(list.get(position).getTitle());
                    miaoshu.setText(list.get(position).getSnippet());
                    longitude=list.get(position).getLatLonPoint().getLongitude();
                    latitude=list.get(position).getLatLonPoint().getLatitude();
                }
            });
    
        }
    
        /**
         * 控件信息初始化
         */
        private void info(){
            back=(ImageButton)findViewById(R.id.mapaddress_back);
            mapView = (MapView) findViewById(R.id.mapaddress_map);
            addresslistview=(ListView) findViewById(R.id.addresslistview);
            search=(Button) findViewById(R.id.mapaddress_search);
            name=(TextView) findViewById(R.id.mapaddress_name);
            miaoshu=(TextView) findViewById(R.id.mapaddress_miaoshu);
            sendlocation=(Button) findViewById(R.id.sendlocation);
            search.setOnClickListener(this);
            sendlocation.setOnClickListener(this);
            back.setOnClickListener(this);
        }
    
        /**
         * 初始化AMap对象
         */
        private void init() {
            if (aMap == null) {
                aMap = mapView.getMap();
                aMap.moveCamera(CameraUpdateFactory.zoomTo(15));
                setUpMap();
            }}
        private void setUpMap() {
            aMap.setLocationSource(MapAddress.this);// 设置定位监听
            aMap.getUiSettings().setMyLocationButtonEnabled(true);// 设置默认定位按钮是否显示
            aMap.setMyLocationEnabled(true);// 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false
            // 设置定位的类型为定位模式 ,可以由定位、跟随或地图根据面向方向旋转几种
            aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE);
            aMap.setOnCameraChangeListener(this);
    
    
        }
        /**
         * 地图移动,经纬度改变的监听
         */
        @Override
        public void onCameraChange(CameraPosition arg0) {
            // TODO Auto-generated method stub
    
        }
    
        @Override
        public void onCameraChangeFinish(CameraPosition arg0) {
            // TODO Auto-generated method stub
            LatLonPoint latp=new LatLonPoint(arg0.target.latitude,arg0.target.longitude);
            PoiSearch(latp);
        }
    
        public void PoiSearch(LatLonPoint lp){
            PoiSearch.Query query = new PoiSearch.Query("","餐饮服务|商务住宅|生活服务","");// 第一个参数表示搜索字符串,第二个参数表示poi搜索类型,第三个参数表示poi搜索区域(空字符串代表全国)
            query.setPageSize(15);// 设置每页最多返回多少条poiitem
            query.setPageNum(0);// 设置查第一页
            poiSearch = new PoiSearch(this,query);
            poiSearch.setOnPoiSearchListener(this);
            poiSearch.setBound(new SearchBound(lp, 500, true));//
            poiSearch.searchPOIAsyn();// 异步搜索
        }
    
        @Override
        public void onPoiSearched(PoiResult arg0, int arg1) {
            list=arg0.getPois();
            AddressAdapter adapter=new AddressAdapter(MapAddress.this,list);
            addresslistview.setAdapter(adapter);
            adapter.notifyDataSetChanged();
        }
        /**
         * 方法必须重写
         */
    
    
    
        protected void onResume() {
            super.onResume();
            mapView.onResume();
        }
    
        /**
         * 方法必须重写
         */
        @Override
        protected void onPause() {
            super.onPause();
            mapView.onPause();
            deactivate();
        }
    
        /**
         * 方法必须重写
         */
        @Override
        protected void onSaveInstanceState(Bundle outState) {
            super.onSaveInstanceState(outState);
            mapView.onSaveInstanceState(outState);
        }
    
        /**
         * 方法必须重写
         */
        @Override
        protected void onDestroy() {
            super.onDestroy();
            mapView.onDestroy();
            if(null != mlocationClient){
                mlocationClient.onDestroy();
            }
        }
        /**
         * 定位成功后回调函数
         */
    
        public void onLocationChanged(AMapLocation arg0) {
            // TODO Auto-generated method stub
    
            if (mListener != null && arg0 != null) {
                if (arg0 != null
                        && arg0.getErrorCode() == 0) {
    
                    mListener.onLocationChanged(arg0);// 显示系统小蓝点
    
    
                } else {
                    String errText = "定位失败," + arg0.getErrorCode()+ ": " + arg0.getErrorInfo();
                    Toast.makeText(this,"定位失败,请点击手动定位",Toast.LENGTH_LONG).show();
                    Log.e("AmapErr",errText);
    
                }
            }
    
        }
        /**
         * 激活定位
         */
        @Override
        public void activate(OnLocationChangedListener arg0) {
            // TODO Auto-generated method stub
    
            mListener = arg0;
            if (mlocationClient == null) {
                mlocationClient =new AMapLocationClient(this);
                mLocationOption = new AMapLocationClientOption();
                //设置定位监听
                mlocationClient.setLocationListener(this);
                mLocationOption.setInterval(500000);
                //设置为高精度定位模式
                mLocationOption.setLocationMode(AMapLocationMode.Hight_Accuracy);
                //设置定位参数
                mlocationClient.setLocationOption(mLocationOption);
                // 此方法为每隔固定时间会发起一次定位请求,为了减少电量消耗或网络流量消耗,
                // 注意设置合适的定位时间的间隔(最小间隔支持为2000ms),并且在合适时间调用stopLocation()方法来取消定位请求
                // 在定位结束后,在合适的生命周期调用onDestroy()方法
                // 在单次定位情况下,定位无论成功与否,都无需调用stopLocation()方法移除请求,定位sdk内部会移除
                mlocationClient.startLocation();
            }
    
        }
        /**
         * 停止定位
         */
        @Override
        public void deactivate() {
            // TODO Auto-generated method stub
            mListener = null;
            if (mlocationClient != null) {
                mlocationClient.stopLocation();
                mlocationClient.onDestroy();
            }
            mlocationClient = null;
        }
    
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            switch (v.getId()) {
                case R.id.mapaddress_search:
                    Intent in=new Intent(this,SearchAddress.class);
                    startActivityForResult(in,3001);
                    break;
                case R.id.sendlocation:
                    if(!miaoshu.getText().toString().equals("")){
                        aMap.getMapScreenShot( this);
                    }
                    else{
                        Toast.makeText(this,"请选择地址后再分享",Toast.LENGTH_LONG).show();
                    }
                    break;
                case R.id.mapaddress_back:
                    Intent intent=new Intent();
                    intent.putExtra("longitude",0);
                    setResult(6600, intent);
                    finish();
                    break;
                default:
                    break;
            }
    
        }
        @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            // TODO Auto-generated method stub
            super.onActivityResult(requestCode, resultCode, data);
            if(!data.getStringExtra("name").equals("")){
                LatLng latp=new LatLng(data.getDoubleExtra("latitude",0),data.getDoubleExtra("longitude",0));
                aMap.moveCamera(CameraUpdateFactory.newLatLng(latp));
                aMap.moveCamera(CameraUpdateFactory.zoomTo(18));
    
            }
        }
    
        @Override
        public void onMapScreenShot(Bitmap arg0) {
            // TODO Auto-generated method stub
    
            try {
                FileOutputStream    out = new FileOutputStream(Environment.getExternalStorageDirectory()+"/"+"locationmap.png");
                if (null != out) {
                    arg0.compress(Bitmap.CompressFormat.PNG, 100, out);
                    out.flush();
                    out.close();
                    Toast.makeText(this, "地理位置图片文件已保存至SDCard下", Toast.LENGTH_LONG).show();
                    Intent intent=new Intent();
                    intent.putExtra("longitude", longitude);
                    intent.putExtra("latitude", latitude);
                    intent.putExtra("name", name.getText().toString());
                    intent.putExtra("miaoshu", miaoshu.getText().toString());
                    intent.putExtra("locationimgpath", Environment.getExternalStorageDirectory() + "/" + "locationmap.png");
                    setResult(6600, intent);
                    finish();
                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                Toast.makeText(this, "没有sdcard或者sdcard不可用", Toast.LENGTH_LONG).show();
            }
    
    
        }
    
        @Override
        public boolean onKeyDown(int keyCode, KeyEvent event) {
    
            if (keyCode == KeyEvent.KEYCODE_BACK
                    && event.getRepeatCount() == 0) {
                //do something...
                Intent intent=new Intent();
                intent.putExtra("longitude",0.00);
                setResult(6600, intent);
                finish();
                return true;
            }
            return super.onKeyDown(keyCode, event);
        }
    }
    MapAddressActivity
    package com.changim.app.ui.adapter;
    
    import java.util.List;
    
    import com.amap.api.services.core.PoiItem;
    import com.changim.app.R;
    
    
    import android.content.Context;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.BaseAdapter;
    import android.widget.TextView;
    
    public class AddressAdapter extends BaseAdapter{
        private List<PoiItem>tipList;
        LayoutInflater  flater;
    
        
        Context context;
        
        public AddressAdapter (Context context,List<PoiItem> tipList) {
            // TODO Auto-generated method stub
            flater=LayoutInflater.from(context);
            this.tipList=tipList;
            
            
            
        }
        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return tipList.size();
        }
    
        @Override
        public Object getItem(int position) {
            // TODO Auto-generated method stub
            return position;
        }
    
        @Override
        public long getItemId(int position) {
            // TODO Auto-generated method stub
            return position;
        }
    
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub
            convertView=flater.inflate(R.layout.mapaddress_left_item,null);
            TextView name,miaoshu;
            name=(TextView) convertView.findViewById(R.id.mapaddress_left_item_name);
            miaoshu=(TextView) convertView.findViewById(R.id.mapaddress_left_item_miaoshu);
            
            
                name.setText(tipList.get(position).getTitle());
                miaoshu.setText(tipList.get(position).getSnippet());
            
            if(position==0){
                //name.setTextColor(Color.RED);
                //miaoshu.setTextColor(Color.RED);
            }
            return convertView;
        }
        
    
    }
    AddressAdapter
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" 
        android:padding="10dp"
        android:gravity="center">
        
        <TextView
            android:id="@+id/searchaddressname"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
             android:text="gg"
             android:textSize="23px"/>
     
        <TextView
            android:layout_marginTop="15dp"
            android:id="@+id/searchaddressmiaoshu"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="gg"
            android:textSize="16px"/>
    
    </LinearLayout>
    address_item.xml
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
        
        <LinearLayout 
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:padding="10dp">
    
        <ImageView
            android:layout_width="20dp"
            android:layout_height="10dp"
            android:layout_gravity="center_vertical"
            android:src="@mipmap/gps"/>
    
       <LinearLayout
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_marginLeft="8dp"
           android:orientation="vertical" >
     
        <TextView
            android:id="@+id/mapaddress_left_item_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="gg"
            android:textSize="18dp" />
     
        <TextView
            android:id="@+id/mapaddress_left_item_miaoshu"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="gg"
            android:textColor="@android:color/darker_gray"
            android:textSize="15dp" />
    
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
    mapaddress_left_item.xml
    package com.changim.app.ui.chat;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    
    import com.changim.app.ui.adapter.SearchAddressAdapter;
    import android.app.Activity;
    import android.app.ProgressDialog;
    import android.content.Intent;
    import android.content.pm.ApplicationInfo;
    import android.content.pm.PackageInfo;
    import android.content.pm.PackageManager;
    import android.content.pm.PackageManager.NameNotFoundException;
    import android.os.Bundle;
    import android.support.v4.app.FragmentActivity;
    import android.text.Editable;
    import android.text.TextWatcher;
    import android.view.KeyEvent;
    import android.view.View;
    import android.view.Window;
    import android.view.View.OnClickListener;
    import android.widget.AdapterView;
    import android.widget.AdapterView.OnItemClickListener;
    import android.widget.ArrayAdapter;
    import android.widget.AutoCompleteTextView;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.ImageButton;
    import android.widget.ListView;
    import android.widget.TextView;
    
    import com.amap.api.maps.AMap;
    import com.amap.api.maps.AMap.InfoWindowAdapter;
    import com.amap.api.maps.AMap.OnMarkerClickListener;
    import com.amap.api.maps.AMapUtils;
    import com.amap.api.maps.SupportMapFragment;
    import com.amap.api.maps.model.Marker;
    import com.amap.api.maps.model.NaviPara;
    import com.amap.api.maps.overlay.PoiOverlay;
    import com.amap.api.services.core.AMapException;
    import com.amap.api.services.core.PoiItem;
    import com.amap.api.services.core.SuggestionCity;
    import com.amap.api.services.help.Inputtips;
    import com.amap.api.services.help.Inputtips.InputtipsListener;
    import com.amap.api.services.help.Tip;
    import com.amap.api.services.poisearch.PoiResult;
    import com.amap.api.services.poisearch.PoiSearch;
    import com.amap.api.services.poisearch.PoiSearch.OnPoiSearchListener;
    import com.changim.app.R;
    
    
    /**
     * AMapV1地图中简单介绍poisearch搜索
     */
    public class SearchAddress extends Activity implements
            TextWatcher,
            OnPoiSearchListener {
    
        private AutoCompleteTextView searchText;// 输入搜索关键字
        private PoiResult poiResult; // poi返回的结果
        private int currentPage = 0;// 当前页面,从0开始计数
        private PoiSearch.Query query;// Poi查询条件类
        private PoiSearch poiSearch;// POI搜索
        private ListView lv;
        private List<Tip> list;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            this.requestWindowFeature(Window.FEATURE_NO_TITLE);
            setContentView(R.layout.address);
            searchText = (AutoCompleteTextView) findViewById(R.id.searchaddress);
            lv=(ListView) findViewById(R.id.address_list);
            searchText.addTextChangedListener(this);// 添加文本输入框监听事件
    
            lv.setOnItemClickListener(new OnItemClickListener() {
    
                @Override
                public void onItemClick(AdapterView<?> parent, View view,
                                        int position, long id) {
                    // TODO Auto-generated method stub
                    System.out.println("00000000000000000000000");
                    System.out.println(list.get(position).getName());
                    System.out.println(list.get(position).getPoiID());
                    System.out.println(list.get(position).getPoint());
                    System.out.println(list.get(position).getAdcode());
                    Intent intent=new Intent(SearchAddress.this,MapAddress.class);
                    intent.putExtra("name",list.get(position).getName());
                    intent.putExtra("miaoshu",list.get(position).getDistrict());
                    intent.putExtra("latitude",list.get(position).getPoint().getLatitude());
                    intent.putExtra("longitude",list.get(position).getPoint().getLongitude());
                    setResult(3001,intent);
                    finish();
                }
            });
    
    
        }
    
    
        public void afterTextChanged(Editable s) {
    
        }
    
    
        public void beforeTextChanged(CharSequence s, int start, int count,
                                      int after) {
    
        }
    
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            String newText = s.toString().trim();
            Inputtips inputTips = new Inputtips(SearchAddress.this,
                    new InputtipsListener() {
    
                        @Override
                        public void onGetInputtips(List<Tip> tipList, int rCode) {
                            if (rCode == 0) {// 正确返回
                                //List<String> listString = new ArrayList<String>();
                            
                                /*for (int i = 0; i < tipList.size(); i++) {
                            
                                    listString.add(tipList.get(i).getDistrict());
                                    
                                }*/
                                list=tipList;
                                SearchAddressAdapter adapter=new SearchAddressAdapter(SearchAddress.this, tipList);
                                lv.setAdapter(adapter);
                                adapter.notifyDataSetChanged();
                            }
                        }
                    });
            try {
                inputTips.requestInputtips(newText,"成都");// 第一个参数表示提示关键字,第二个参数默认代表全国,也可以为城市区号
    
            } catch (AMapException e) {
                e.printStackTrace();
            }
        }
    
    
        @Override
        public void onPoiSearched(PoiResult arg0, int arg1) {
            // TODO Auto-generated method stub
    
        }
    
        @Override
        public boolean onKeyDown(int keyCode, KeyEvent event) {
            // TODO Auto-generated method stub
            Intent intent=new Intent(SearchAddress.this,MapAddress.class);
            intent.putExtra("name","");
            setResult(3001,intent);
            finish();
            return super.onKeyDown(keyCode, event);
        }
    
    
    
    
    
    }
    SearchAddress
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
        
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:background="#00b4ef"
            android:orientation="horizontal" >
    
            <ImageButton
                android:id="@+id/mapaddress_back"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="4"
                android:background="#00000000"
                android:src="@mipmap/left_back" />
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:layout_gravity="center_vertical"
                android:orientation="horizontal"
                android:layout_weight="2" 
                android:background="@drawable/fillet">
    
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:src="@mipmap/seek"
                    android:layout_marginLeft="5dp"/>
    
               
            <AutoCompleteTextView
                android:id="@+id/searchaddress"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginLeft="5.0dip"
              android:background="@null"
                android:completionThreshold="1"
                android:dropDownVerticalOffset="1.0dip"
                android:hint="请输入关键字"
                android:imeOptions="actionDone"
                android:inputType="text|textAutoComplete"
                android:maxLength="20"
                android:paddingRight="37.0dip"
                android:singleLine="true"
                android:textColor="#000000"
                android:textSize="16.0sp" />
    
               
    
            </LinearLayout>
    
            <Button
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:layout_weight="3.5"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="8dp"
                android:layout_marginRight="5dp"
                android:layout_marginBottom="8dp"
                android:layout_gravity="center_vertical"
                android:textSize="20dp"
                android:textColor="@android:color/white"
                android:background="@drawable/sure"
                android:text="取消"/>
            
        </LinearLayout>
    
        <ListView
            android:id="@+id/address_list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
        </ListView>
    
    </LinearLayout>
    address.xml
  • 相关阅读:
    10 个深恶痛绝的 Java 异常。。
    为什么公司宁愿 25K 重新招人,也不给你加到 20K?原因太现实……
    推荐一款代码神器,代码量至少省一半!
    Spring Cloud Greenwich 正式发布,Hystrix 即将寿终正寝。。
    hdu 3853 LOOPS(概率 dp 期望)
    hdu 5245 Joyful(期望的计算,好题)
    hdu 4336 Card Collector(期望 dp 状态压缩)
    hdu 4405 Aeroplane chess(概率+dp)
    hdu 5036 Explosion(概率期望+bitset)
    hdu 5033 Building (单调栈 或 暴力枚举 )
  • 原文地址:https://www.cnblogs.com/zzw1994/p/5292500.html
Copyright © 2011-2022 走看看