Guest
Public paste!

Untitled

By: a guest | Feb 9th, 2010 | Syntax: None | Size: 0.78 KB | Hits: 96 | Expires: Never
Copy text to clipboard
  1. public class MainListActivity extends ListActivity{
  2.     @Override
  3.     public boolean onKeyDown(int keyCode, KeyEvent event)  {
  4.         if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ECLAIR
  5.                 && keyCode == KeyEvent.KEYCODE_BACK
  6.                 && event.getRepeatCount() == 0) {
  7.             // Take care of calling this method on earlier versions of
  8.             // the platform where it doesn't exist.
  9.             onBackPressed();
  10.         }
  11.  
  12.         return super.onKeyDown(keyCode, event);
  13.     }
  14.  
  15.     @Override
  16.     public void onBackPressed() {
  17.         // This will be called either automatically for you on 2.0
  18.         // or later, or by the code above on earlier versions of the
  19.         // platform.
  20.                 finish();
  21.         return;
  22.     }
  23. }