Events

The main thread of an Android process is run as an event loop. Long running processes can cause stuttering, slow responses, and the Application Not Responding warning.

  • All UI updates are done on the main thread
  • No networking is allowed on the main thread

Listeners

Listeners respond to events. They are normally implemented as anonymous class or a lambda.

closeButton.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {
    finish();
  }
});

OnClickListeners

can be set in xml

fun funName (view: View) {
  //actions
}

results matching ""

    No results matching ""