I am working on an android application. In an activity at the bottom of the page, I am showing a popupWindow and replaced the keyboard with this popupwindow. This popupWindow is having a searchview inside it, so when searchview will be in focus the keyboard will be shown and popupWindow will be slide up. Now when I press Back Button (Phone's Back Button) then keyboard as well as popupwindow both are getting closed. So, I want to close only keyboard here and popupwindow should be slide down after keyboard will be closed.
I tried the below things :
setBackgroundDrawable(new BitmapDrawable());
poupupWindow.setFocusable(true);
Applied KeyListner also on popupWindow, but it's not working.
popupWindow.getContentView().setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK &&
event.getAction() == KeyEvent.ACTION_DOWN) {
return true;
} return false;
}
});
Please help me if anyone have idea about this. Thanks a ton in advanced :)