Advertisement
MarRab

ActionBar - Back Button

Sep 18th, 2014
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.39 KB | None | 0 0
  1. // 1
  2.     getActionBar().setDisplayHomeAsUpEnabled(true);
  3. // 2
  4.     @Override
  5.     public boolean onOptionsItemSelected(MenuItem item) {
  6.             switch (item.getItemId()) {
  7.             case android.R.id.home:
  8.                 onBackPressed();
  9.                 return true;
  10.             }
  11.  
  12.         return super.onOptionsItemSelected(item);
  13.     }
  14.    
  15.     @Override
  16.     public void onBackPressed() {
  17.         super.onBackPressed();
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement