`

callback interface

 
阅读更多

callback接口:

拿View的OnclickListener接口为例

View 是 android 视图 的基类。

View 拥有 public interface OnclickListener 和 setOnClickListener(View.OnClickListener l)方法

OnClickListener接口有接口方法 void onClick(View v)

如在某个Activity中有一个Button 这个Button是View的子类。继承了View的OnClickList接口和setOnClickListener方法。在当前的Activity中可以implements View.OnClickListener接口。也可以new一个匿名内部类来实现接口的onClick方法。Button的实例就可以invoke setOnClickListener方法设置接口的实现。onClick方法在View中的callOnClick()和performClick()两个方法中背调用。

其中callOnClick()方法在ZoomButton的Runnable接口方法run()中异步调用。

runnable背handle.post(ruaable)传入Handle。

该方法的最终执行时在handle中 handleCallback方法中背启动。这个handleCallback方法背dispatchMessage方法调用。dispatchMessage方法其中一个方向是背Looper的static方法loop()执行。

至此,一个callback的接口背执行完毕。

 

分享到:
评论

相关推荐

    (Actuate e.Spreadsheet callback Interface)用程序制作报表的实例.doc

    (Actuate e.Spreadsheet callback Interface)用程序制作报表的实例.doc

    Android代码-Android网格锁屏幕视图

    An Android grid lock screen view with a callback interface. ScreenShot Demo Usage Gradle compile 'com.takwolf.android:lock9view:0.0.11' Layout example 1 Layout example 2 PS : If use "lock9_...

    AN-IND-1-012_CAPL_Callback_Interface.pdf

    AN-IND-1-012_CAPL_Callback_Interface

    【英文参考资料】-AUTOSAR学习资料无人驾驶-AN-IND-1-012_CAPL_Callback_Interface

    【英文参考资料】-AUTOSAR学习资料无人驾驶-AN-IND-1-012_CAPL_Callback_Interface

    Android中使用ListView绘制自定义表格技巧分享

    把源码贴一下(因为该点是主界面中的一部分,不便于放整个Demo) 自定义适配器,CallBackInterface是自定义的回调接口,这里定义回调是因为数据输入时需要及时保存 代码如下: public class SiteDetailViewAdapter ...

    CANoe的编程语言CAPL 诊断接口,包括例子和参考

    Information and explanation on the CAPL Callback Interface (CCI) for diagnostics in CANoe, including examples and references

    Android平台下的RTP,RTCP实现

    RTPAppIntf - the mininum callback interface RTPCAppIntf - optional interface for receing RTCP packets RTCPAVPFIntf - optional interface for RTP with feedback DebugAppIntf - optional interface for ...

    ViewPager 放大缩小左右移动

    * Callback interface for responding to changing state of the selected page. */ public interface OnPageChangeListener { /** * This method will be invoked when the current page is scrolled, ...

    interfaceCallback

    该程序简单的讲述了接口回调的实现,程序明朗,希望大家多多努力提升。

    java8看不到源码-PersianDT:JAVA的PesianDate

    因此,如果您想获得异步响应,您必须使用CallBack Interface并且要使用它,您必须知道如何在 PersianDt 中通过以下几种方式填充和获得响应: 实现回调 Lambda/方法参考(JAVA8) 匿名工具 如果你有任何问题 阅读 不...

    FirstCallbackExample

    FirstCallbackExample 这是此示例中的回调的第一个版本// The callback interfaceinterface MyCallback { void callbackCall ();}// The class that takes the callbackclass Worker { MyCallback callback; void ...

    android-util

    ## maven依赖###添加maven依赖 ...通知中心iOS NotificationCenter android实现//callback interfacepublic interface SampleLoginCallback { interface Login { void onLogin(String userName); void onLogout();

    MofunPhotoCropper:相片裁切器,专用于android5.0 +

    Thanksforked from and modify by [针对... By providing a simple callback interface for developers and encapsulating the tricky things of cropping photos into a library. It makes the logic much more easie

    MTK10A培训资料

    3 、Callback Manager 4 、Screen Group 5 、Scenario Interface 6 、Menu Common UI 7 、MMI Resource 8 、Popup & Confirm 9 、Notification Manager 10、New Input Handler 11、Primitive Flush 12、Small Screen...

    appcan MAS开发

    interface.xml 11 application.xml 12 policy_[Policy Name].xml 12 Initialize.js 13 MAS适配器的实现 13 MAS适配器运行环境 13 MAS适配器 13 Param对象 14 Robot对象 14 Request对象 16 Response对象 16 IF对象 16...

    node-watch-interface:node.js watch 模块的接口

    require('watch-interface').on(directory, options, callback) 开始以递归方式监视目录。 directory : 字符串,应该关注的内容的根directory options :对象exclude :如果应忽略特定文件,则应匹配的字符串、...

    基于go语言的定时脚本任务.zip

    基于go语言的定时脚本任务.zip 示例代码 package xz_crontab ...func callback(par ...interface{})(err error ) { log.Println("回调参数",par[0],par[1]) time.Sleep(6*time.Second) return }

    kotlin 定义接口并实现回调的例子

    interface CallBack{ fun callBack(info : String) } 2、实现接口 : 为继承\实现 class CallBacks : CallBack{ override fun callBack(info : String){ Log.d(MainApp,current info $info) } } 或者 private ...

    ALV常用参数的详细描述1

    i_interface_check = \'\' 接口一致性检查 i_callback_program = sy-repid 当前程序名 is_layout = is_layout 输出样式 it_fieldcat = fieldcat[] 字段定义描述表 i_callback_pf_status_set = \'PF_STATUS_SET\...

    CISCO 技术大集合

    建立静态路由 ip route prefix mask {address | interface} [distance] [tag tag] [permanent] Prefix :所要到达的目的网络 mask :子网掩码 address :下一个跳的IP地址,即相邻路由器的端口地址。 interface :...

Global site tag (gtag.js) - Google Analytics