zoukankan      html  css  js  c++  java
  • 关于android监听事件的一些理解

    android 加你通一般来说 大家都明白 但是 对于新手来说 总是有点似是而非 Julia 

    自定义的点击事件 以及监听·

    public class MyPolygon extends Polygon {

    public MyPolygon(MapView mMapView) {

    }

    private OnMyPolygonClickListener mOnMyPolygonClickListener; 4. 监听的对象


    @Override public boolean onSingleTapConfirmed(final MotionEvent event, final MapView mapView){
    Projection pj = mapView.getProjection();
    GeoPoint eventPos = (GeoPoint)pj.fromPixels((int)event.getX(), (int)event.getY());
    boolean tapped = contains(event);
    if (tapped) {
    return mOnMyPolygonClickListener.onMyPolygonClick(this, mapView, eventPos); 、、在这里 去触发监听事件 3.
    } else
    return tapped;
    }


    public interface OnMyPolygonClickListener { //自定义 面覆盖物监听 这创建自定义的接口 然后 里面 有方法 全是自定义的 1.
    boolean onMyPolygonClick(MyPolygon polygon, MapView mapView, GeoPoint eventPos);
    }

    public void setOnMyPolygonClickListener(OnMyPolygonClickListener listener){ 、、这里是 如何设置监听 2.
    mOnMyPolygonClickListener = listener;
    }


    这4步算是传建一个完整的自定义监听 然后在另一个activity里使用


    }


    这里是使用 1. 去实现监听,MyPolygon.OnMyPolygonClickListener
    public class MulchOverlay extends FolderOverlay implements OnOverlayListener ,MyMark.OnMyMarkerClickListener,MyPolyline.OnMyLineClickListener,MyPolygon.OnMyPolygonClickListener{
    2.去 set(0设置)监听 

    polygon.setOnMyPolygonClickListener(this); this指代的是 所实现的 listener 这里是MyPolygon.OnMyPolygonClickListene 


    3. 重写方法 这里一般是 OnMyPolygonClickListen。的onMyPolygonClick()方法


















  • 相关阅读:
    27. Remove Element
    列表变成字典
    1. Two Sum
    CVPR2019:What and How Well You Performed? A Multitask Learning Approach to Action Quality Assessment
    959. Regions Cut By Slashes
    118. Pascal's Triangle
    loj3117 IOI2017 接线 wiring 题解
    题解 NOI2019 序列
    题解 省选联考2020 组合数问题
    题解 Educational Codeforces Round 90 (Rated for Div. 2) (CF1373)
  • 原文地址:https://www.cnblogs.com/dushutai/p/12924204.html
Copyright © 2011-2022 走看看