android GoogleMap定位(四)
根据输入的名称查询
注:地点输入错误的时候会导致程序崩溃,暂没做处理。(可进行提示的)
主界面:
Java代码
package com.hc;
import java.util.List;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.Toast;
public class AddressActivity extends MapActivity {
/** Called when the activity is first created. */
Button locBn;
MapView mv;
EditText address_value;
MapController controller;
Bitmap posBitmap;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.address);
posBitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.icon);
mv = (MapView) findViewById(R.id.mv);
address_value = (EditText) findViewById(R.id.address_value);
// 显示放大缩小控制按钮
mv.setBuiltInZoomControls(true);
controller = mv.getController();
locBn = (Button) findViewById(R.id.location);
locBn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String address = address_value.getEditableText().toString().trim();
if (address.equals("")) {
相关新闻>>
- 发表评论
-
- 最新评论 更多>>