How to detect android back key when keyboard is open?
I want hide listview when keyboard is hide.
i've used below code
final View activityRootView = findViewById(R.id.globallayout);
activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout()
{
int heightDiff = activityRootView.getRootView().getHeight() - activityRootView.getHeight();
if (heightDiff > 55)
{
//keyboard is showing.
}
else {
if(PopUpLayoutList.getVisibility()==View.VISIBLE){
PopUpLayoutList.setVisibility(View.GONE);
}
}
}
});
But , if the list contains more than 500 rows . the keyboard not hide properly. its take 5 to 10 secs.
How to solve this?