public class MaiN extends Activity { private LocationClient mLocationClient;//定位SDK的核心类 TextView city,onclik; ListView lv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); city=(TextView) findViewById(R.id.gps_city); onclik=(TextView) findViewById(R.id.textView1); lv=(ListView) findViewById(R.id.lv1); logicCode(); } private void logicCode() { // TODO Auto-generated method stub mLocationClient = ((LocationApplication)getApplication()).mLocationClient; ((LocationApplication)getApplication()).mLocationResult = city;//调用LocationApplication,获得需要的信息 // onclik.setOnClickListener(new OnClickListener() { // // public void onClick(View v) { InitLocation(); mLocationClient.start(); // // } // }); Listlist=new ArrayList (); list.add("上海"); list.add("天津"); list.add("深圳"); list.add("衡水"); list.add("香港"); list.add("香1港"); lv.setAdapter(new ArrayAdapter (MaiN.this, android.R.layout.simple_list_item_1, list)); lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { Intent in=new Intent(MaiN.this,MainActivity.class); startActivity(in); } }); } private void InitLocation(){ LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationMode.Hight_Accuracy);//设置高精度定位定位模式 option.setCoorType("bd09ll");//设置百度经纬度坐标系格式 option.setScanSpan(1000);//设置发起定位请求的间隔时间为1000ms option.setIsNeedAddress(true);//反编译获得具体位置,只有网络定位才可以 mLocationClient.setLocOption(option); } }