Android - Back button in the title bar

前端 未结 26 2358
南方客
南方客 2020-12-04 07:02

In many apps (Calendar, Drive, Play Store) when you tap a button and enter a new activity, the icon in the title bar turns into a back button, but for the app I am making, i

26条回答
  •  再見小時候
    2020-12-04 07:37

    If you are using an ActionBar you're going to want to read up on this documentation http://developer.android.com/reference/android/app/ActionBar.html#setDisplayHomeAsUpEnabled(boolean)

    Then you have to overwrite the method onOptionsItemSelected(MenuItem) and look for the android.R.id.home event to come in. Then you know the user has clicked on that back button on the actionbar

提交回复
热议问题