Skip to content

Instantly share code, notes, and snippets.

@luizmarcus
Created February 22, 2016 23:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luizmarcus/bf6375e394814ef139f0 to your computer and use it in GitHub Desktop.
Save luizmarcus/bf6375e394814ef139f0 to your computer and use it in GitHub Desktop.
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