附个例子吧,方便你研究。 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); onCreate(); mButton=(Button)findViewById(R.id.button); Log.d("location", mButton+""); mButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Log.d("location", mButton+""); mLocationClient.start(); } }); 注意那个mLocationClient.start();这是教程上没有的,而且是关键的。这段程序不完整,只是做个参考。 mTextView=(TextView)findViewById(R.id.TextView); // mLocationManager =(LocationManager) getSystemService(Context.LOCATION_SERVICE); }
51,396
社区成员
85,820
社区内容
加载中
试试用AI创作助手写篇文章吧