Dmitry Zaitsev Dmitry Zaitsev - 3 years ago 104
Android Question

How to handle "Up" button?

How to handle "Up" button (SDK version 11+)? I am referring to the one at the top of screen, that holds the application icon.

In Android Design articles it was named as "Up button", but I didn't found it (or similar) in KeyEvent fields.

Answer Source

Implement onOptionsItemSelected() and watch for "menu" events, as is described in the documentation.

public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
            // do something useful

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download