Possible Duplicate:
How can I convert a key code into a char or string?
Hey I'm pretty new to Android and unsure how to use getKeyCode. I have this
public boolean onKeyDown(int keyCode, KeyEvent event)
{
switch(keyCode)
{
case KeyEvent.KEYCODE_DPAD_RIGHT:
Toast.makeText(getApplicationContext(), "Pressed DPAD Right Button",
Toast.LENGTH_LONG).show();
return true;
case KeyEvent.KEYCODE_DPAD_LEFT:
Toast.makeText(this, "Pressed DPAD Left Button",
Toast.LENGTH_LONG).show();
return true;
}
return super.onKeyDown(keyCode,event);
}
But I want to change a textview to say what button was pressed. How do I pass the keyCode into the setText function? I already have it all linked up, I just need the keyCode variable to put into
txt2.setText(Integer.toString(getKeyCode()));