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()方法


















  • 相关阅读:
    android:versionCode和android:versionName 用途
    ProgressDialog使用总结
    对 Android 开发者有益的 40 条优化建议
    Android TextView换行问题
    Android TextView自动换行文字排版参差不齐的原因
    Python 生成requirement 使用requirements.txt
    PLSQL简介
    python魔法方法详解
    深入了解Token认证的来龙去脉
    数组、链表、栈、队列和STL
  • 原文地址:https://www.cnblogs.com/dushutai/p/12924204.html
Copyright © 2011-2022 走看看