Bus 建议使用单例模式,这里我不做详细说明
if(bus==null){
bus=newBus(ThreadEnforcer.MAIN);
}
1,编写一个对象
public classGetValue {
Stringvalue;
publicGetValue(String value) {
this.value= value;
}
publicString getValue() {
returnvalue;
}
public voidsetValue(String value) {
this.value= value;
}
}
2,在APPlication中注册bus
bus.register(this);
3,编写订阅者,这里可以编写多个订阅者
@Subscribe
public voidGetsdg(GetValue getValue){
mytv.setText(getValue.getValue());
}
。。。。。。。。
4,执行
bus.post(newGetValue("我晒"));
非常简单,强大