Created
February 22, 2016 23:40
-
-
Save luizmarcus/bf6375e394814ef139f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends Activity { | |
private EventBus bus = EventBus.getDefault(); | |
private TextView view; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
view = (TextView) findViewById(R.id.text); | |
// Registrar o eventbus | |
bus.register(this); | |
} | |
@Override | |
protected void onDestroy() { | |
// Destruir o registro | |
bus.unregister(this); | |
super.onDestroy(); | |
} | |
//Método que atualiza o TextView de acordo com o evento obtido | |
public void onEvent(Evento evento){ | |
view.setText(evento.getAlerta()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment