Android : BackPressed in Fragment not functioning properly

on Thursday, September 18, 2014


I have the following code:



v = inflater.inflate(R.layout.fragment_color, container, false);
v.setFocusableInTouchMode(true);
v.requestFocus();
v.setOnKeyListener(new View.OnKeyListener() {

@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {

if (keyCode == KeyEvent.KEYCODE_BACK) {
if (mMenu.isOpened()) {
mMenu.closeMenu();
} else {
}
}
return false;
}
});


When I press the back button, my menu closes like it should, but the app closes as well and it should not.


What am I doing wrong with what I have here? any help would be appreciated.


0 comments:

Post a Comment