navigation MenuItem in toolbar doesn't trigger onOptionsItemSelected

前端 未结 3 1641
野趣味
野趣味 2021-01-23 18:18

I\'m trying to use the navigation drawer with toolbar, but pressing the navigation button doesn\'t trigger the onOptionsItemSelected handler and the list doesn\'t open.

3条回答
  •  礼貌的吻别
    2021-01-23 18:46

    write this

      getSupportActionBar().setDisplayShowHomeEnabled(true);
    

    just after you set your toolbar

    and remove

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    

    this will take you to previous task if you have any which might give you an unexpected behavior

提交回复
热议问题