Android程序设计漳州师范学院计算机科学与工程系第3章Java语法在Android的使用第3章Java语法在Android的使用Interface多用于实现回调(CallBack)函数
回调函数(CallFunction)回调函数就是一个通过函数指针调用的函数
如果你把函数的指针(地址)作为参数传递给另一个函数,当这个指针被用为调用它所指向的函数时,我们就说这是回调函数
1interface的使用第3章Java语法在Android的使用interface的代码架构定义interface3
1interface的使用Package包含该文件的包名publicclassInterfaceServer{publicinterfaceOnUpKeyLisnter{publicvoidOnUpkey();}privateOnUpKeyLisntermOnUpkeyLisnter=null;publicvoidOnUpKey(){if(mOnUpkeyLisnter
=null)mOnUpkeyLisnter
OnUpkey();}publicvoidsetOnUpKeyLisnter(OnUpKeyLisnterh){mOnUpkeyLisnter=h;}}第3章Java语法在Android的使用使用InterfaceServer在Java中没有指针的概念,一个class对象就是一个指针
1interface的使用Package包含该文件的包名publicclassInterfaceClient{InterfaceServermServer=newInterfaceServer();InterfaceServer
OnUpKeyLisnterh=newInterfaceServer
OnUpKeyLisnter(){publicvoidOnUpkey();{完