While using ViewFlipper is it possible to map the back button to go to the previous View rather than back out of the entire application?

StackOverflow https://stackoverflow.com/questions/8852624

  •  28-10-2019
  •  | 
  •  

Question

My application is set up using ViewFlipper so that I have one main View which links to three other Views, each through their own button. As I've set it up this way, when I'm on one of the three other Views if I press the back button on my android device it backs all the way out of the app. I Just wanted to know if it was possible to map it to just go back to the main View?

Was it helpful?

Solution

Override onKeyDown() :

@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
    if (keyCode == KeyEvent.KEYCODE_BACK)
        {
            //Place your code here!
        }
    return true;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top