2
I am trying to use the back button action to show a menu in my application, with the onKeyUp method. Once 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 normal menu, in the third is a search screen, and when I go to it, the keyboard automatically goes up, and the menu disappears, because at this moment it is unnecessary.
My difficulty is showing this menu again after being clicked the back button, it works in a certain way, but only appears in the second click of the back button. That is, the first click only serves to download the keyboard, and the second that appears the menu. But I want that in the first click already download the keyboard and appear the menu, and I am not getting. Follow the methods, all this 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 doesn’t work at first click ?? How would it work ?? I have two options: identify when the keyboard is downloaded, or when the back key is clicked, to show the menu. I accept suggestions since jpa thank you.
Because it’s a friend, but I don’t understand very well about custom view. You could explain in more detail ?
– Berg Ferreira
Comrade, these are many steps to explain about Custom View and the answer would be even outside the topic of your question. The answer to your original question has already been given. Your difficulty in implementing a Custom View is already another question. I should post on my www.tinmegali.blog with a tip on this soon. You can wait or open a question about Custom View at stackoverflow. Good luck.
– Tin Megali
I got it, the way I said it worked. Obgggg
– Berg Ferreira