【问题标题】:Can't finish a MapActivity无法完成 MapActivity
【发布时间】:2012-05-24 23:16:28
【问题描述】:

我已经为一个 android 应用程序创建了这个活动:

http://developer.android.com/resources/tutorials/views/hello-mapview.html

现在我想完成 MapActivity OnTouch,但我不知道该怎么做。

我已经在 HelloItemizedOverlay 类上尝试过这个,但不起作用:(我正在使用 mapView 来获取 GeoPoint 的坐标!)

public boolean onTouchEvent(MotionEvent event, MapView mapView) {
      finish();
}

非常感谢!

【问题讨论】:

    标签: java android google-maps mapactivity


    【解决方案1】:

    将 Activity 传递给 HelloItemizedOverlay 并在 Activity 上调用 finish()

    private Activity mActivity;
    
     public HelloItemizedOverlay(Drawable defaultMarker, Activity activity) {
      super(boundCenterBottom(defaultMarker));
      mActivity = activity;
     }
    
     public boolean onTouchEvent(MotionEvent event, MapView mapView) {
          mActivity.finish(); 
     }
    

    【讨论】:

    • 没问题,如果这解决了我们的问题,请确保您单击我的答案旁边的大检查,这样每个人都知道您的问题已解决。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-06
    • 2015-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-22
    • 2019-05-27
    相关资源
    最近更新 更多