码迷,mamicode.com
首页 > 其他好文 > 详细

事件回调

时间:2014-06-02 21:33:20      阅读:265      评论:0      收藏:0      [点我收藏+]

标签:android   c   style   class   code   a   

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

  

 

 

  

 

 

事件回调,布布扣,bubuko.com

事件回调

标签:android   c   style   class   code   a   

原文地址:http://www.cnblogs.com/muyable/p/3762530.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!