Android 回调机制

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lyp13243189027/article/details/82767957

1,定义回调接口

public interface SlotCard {
    void onSlotListener(String carid);
}

 

2,定义类A

public class A{

 public static SlotCard slotCardlistener;

slotCardlistener.onSlotListener(card);

public static void setOnSlotCardListenre(SlotCard listener){
    slotCardlistener = listener;
}

}

3.定义类B

public class B implements SlotCard{

A.setOnSlotCardListenre(this);

@Override
public void onSlotListener(String carid) {
    Log.d("888888888888888","carid = "+carid);
}

}

阅读更多
换一批

没有更多推荐了,返回首页