0

I have a basic question about android development. In my app i have a autocomplete box. When user click on a menu button, autocomplete become visible. When user clicks on an entry in autocomplete, the text views show it. I want to use back button such that when user presses it . Textview become invisible , on again click autocomplte disappears and than on third click app exits. But in my app on a single click app exits. I am a new to development so doesn't know much about it, so i ask here.

Khayam Gondal
  • 2,366
  • 2
  • 28
  • 40
  • 2
    Technically, @ZouZou points in the right direction. But I would think twice before introducing a UI behaviour which is unique to a single app. – class stacker Apr 28 '13 at 14:50

1 Answers1

1
@Override
   public boolean onKeyDown(int keyCode, KeyEvent event) {
       if ((keyCode == KeyEvent.KEYCODE_BACK)) {
         //stuff
       }
    return super.onKeyDown(keyCode, event);
   } 

Since API 5 :

 @Override
    public void onBackPressed() {
        //stuff

    }
stinepike
  • 54,068
  • 14
  • 92
  • 112
Alexis C.
  • 91,686
  • 21
  • 171
  • 177