zoukankan      html  css  js  c++  java
  • 事件回调

    Listener是一个接口

    An event listener is an interface in the View class that contains a single callback method. These methods will be called by the Android framework when the View to which the listener has been registered is triggered by user interaction with the item in the UI.

    1.View里面有接口的声明,以及接口的定义(接口里面有方法)。

    2.为View设置监听器(特定已经实现的接口)。

    public class View implements Drawable.Callback, KeyEvent.Callback, AccessibilityEventSource {
     

      private OnKeyListener mOnKeyListener;

      public interface OnKeyListener {
            /**
             * Called when a key is dispatched to a view. This allows listeners to
             * get a chance to respond before the target view.
             *
             * @param v The view the key has been dispatched to.
             * @param keyCode The code for the physical key that was pressed
             * @param event The KeyEvent object containing full information about
             *        the event.
             * @return True if the listener has consumed the event, false otherwise.
             */
            boolean onKey(View v, int keyCode, KeyEvent event);
        }

      public void setOnKeyListener(OnKeyListener l) {
            mOnKeyListener = l;
        }

      

     

     

      

  • 相关阅读:
    SVD与PCA
    Service(二):通信
    Service(一):认识service、绑定Service
    计划(四)
    Android studio 安装过程中遇到的问题
    UFLDL 教程学习笔记(四)
    opencv之dft及mat类型转换
    《第一行代码》(四)
    《第一行代码》
    计划(三)
  • 原文地址:https://www.cnblogs.com/muyable/p/3762530.html
Copyright © 2011-2022 走看看