1

Отображаю кнопку "назад" в ActionBar

toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

Пытаюсь обработать нажатие, а не срабатывает.

public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.home) {
......
return true;
}

Может где-то нужно заранее определить кнопке назад @+id/home?

1 ответ 1

7

android.R.id.home вместо R.id.home

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.