I'm trying to use the back button action to pop up a menu in my application, with the onKeyUp method. As soon as the back key was clicked, the menu should immediately appear.
In my application I work with tabHost, there are 3 screens, in the first two there is a normal menu, in the third it is a search screen, and when I go to it, the keyboard automatically goes up, and the menu disappears, because at the moment it is unnecessary.
My problem is being to show this menu again after clicking the back button, it works in a way, but only appears on the second click of the back button. That is, the first click is only for downloading the keyboard, and the second that appears the menu. But I want the first click to lower the keyboard and show the menu, and I can not. Follow the methods, all in MainActivity.
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (event != null && KeyEvent.KEYCODE_BACK == event.getKeyCode() || keyCode == KeyEvent.KEYCODE_BACK) {
Log.i("BOTAO VOLTAR", "BOTÃO VOLTAR CLICADO!!!");
hideShowTabs(false);
}
return false;
}
public void hideShowTabs(boolean option) {
if (option)
tabHost.getTabWidget().setVisibility(View.GONE);
else
tabHost.getTabWidget().setVisibility(View.VISIBLE);
}
Can anyone tell me why it does not work on the first click ?? How would it work? I have two options to do: identify when the keyboard is downloaded, or when the back key is clicked, to display the menu. I accept suggestions, thank you jpa.