美文网首页
android otto框架讲解

android otto框架讲解

作者: gc_jp | 来源:发表于2017-05-03 16:28 被阅读0次

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("我晒"));

非常简单,强大

相关文章

网友评论

      本文标题:android otto框架讲解

      本文链接:https://www.haomeiwen.com/subject/wudrbttx.html