package test;
/**
* 父类
* @author
*
*/
public class Father {
private SonFuctionListener mListenr;
public Father() {
}
public void setSonListener(SonFuctionListener listener) {
mListenr = listener;
}
public interface SonFuctionListener {
void callTestMethod1();
}
public void realizeWay() {
if (mListenr != null) {
mListenr.callTestMethod1();
}
}
}
package test;
import test.Father.SonFuctionListener;
/**
* 子类
* @author
*
*/
public class Son extends Father implements SonFuctionListener{
public Son() {
setSonListener(this);
}
public void testSonMethod(String str) {
System.out.println(str + ": this is testSonMethod");
}
@Override
public void callTestMethod1() {
testSonMethod("通过监听回调");
}
}
package test;
/**
*
* @author
*
*/
public class TestTwo {
public static void main(String[] args) {
//通过监听回调
son.realizeWay();
}
}