How to track the down arrow button in virtual keyb

2019-02-17 12:15发布

问题:

In the above figure i want to listen for down arrow( i have marked it in red colour, the key one which is used to hide the keyboard). I have tried to get it action through menu options, viewconfiguration class etc. But it is not useful. Is there any method, listeners or any callback event to track this button. Please let me know your suggestions and thoughts. Any help in this regard is highly appreciable

Thanks inAdvance

回答1:

In your activity, override this method: http://developer.android.com/reference/android/app/Activity.html#onBackPressed()



回答2:

If I am not you talking about this method

public boolean onKeyDown(int keyCode, KeyEvent event) {
super.onKeyDown(keyCode, event);
    switch(keyCode)
    {

    case KeyEvent.KEYCODE_BACK:
     Toast.makeText(KeyActions.this, "Pressed Back Button", Toast.LENGTH_SHORT).show();

        return true;
    }

    return false;
}