nexus490
nexus490

Reputation: 817

Key event listening

Can someone give me a quick crash course in using the physical keypad for android?

I have this method in my code:

public boolean OnKeyDown(int keyCode, KeyEvent event)
{
    switch (keyCode) {

    case KeyEvent.KEYCODE_1:
        setContentView(R.layout.about);
        break;
    }

    return true;
} 

yet when i press the physical 1 button in the emulator nothing happens.

am i missing something?

Upvotes: 0

Views: 311

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007533

Step #1: Add the @Override annotation.

Step #2: When the compiler complains that there is no OnKeyDown method, rename it to onKeyDown(). :-)

Upvotes: 4

Related Questions