Action bar Back button not working

前端 未结 13 1765
再見小時候
再見小時候 2020-12-01 03:13

with the help of these Android Docs.I am trying to do a action bar Back button.I get an Action Bar Back Button like these below image:

相关标签:
13条回答
  • 2020-12-01 04:12

    if the home button is shown. you should add an action to the home button through onOptionItemSelected fun (arrow in your case) by default there's no action. so it's totally normal that it's not working. Please add this fun to your activity :

     override fun onOptionsItemSelected(item: MenuItem): Boolean {
            return when {
                item.itemId == android.R.id.home -> {
                    finish()
                    true
                }
                else -> super.onOptionsItemSelected(item)
            }
        }
    
    0 讨论(0)
提交回复
热议问题