K
K
Koshkasobaka2021-07-14 13:32:06
Android
Koshkasobaka, 2021-07-14 13:32:06

Why doesn't the back arrow in the fragment work?

I bind the ToolBar and create an arrow:
(activity as MainActivity).setSupportActionBar(binding!!.tbDetail)
(activity as MainActivity).supportActionBar?.setDisplayHomeAsUpEnabled(true)

Handle the click:

binding!!.tbDetail.setOnMenuItemClickListener {
when(it.itemId) {
R.id.home -> { Toast.makeText(context, "Home button pressed", Toast.LENGTH_LONG).show() }
R.id.delete -> { Toast.makeText(context, "Submit button pressed", Toast.LENGTH_LONG).show() }
}
true
}

item delete works, but the back arrow doesn't. Maybe I'm not referring to the id arrow correctly (I don't know where to look), but of the id offered by the studio, this is the only one that fits logically by name

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2021-07-14
@Koshkasobaka

android.R.id.home

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question