• 事件回调


    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;
        }

      

     

     

      

  • 相关阅读:
    cookie和session区别
    jsp编写页面时常见错误提示
    web处理jsp文件的三个阶段
    JSP页面元素
    B/S与C/S区别
    url组成部分
    css选择器
    ol,ul,dl,table标签的基本语法
    剑指offer-把二叉树打印成多行
    剑指offer-从上往下打印二叉树
  • 原文地址:https://www.cnblogs.com/muyable/p/3762530.html
Copyright © 2020-2023  润新知