ActionBar 'up' button destroys parent activity, 'back' does not

前端 未结 4 627
旧巷少年郎
旧巷少年郎 2020-12-13 01:48

I have a relatively simple Android app with one Activity showing a list of items and another showing details of a selected item. I start the list activity, whi

4条回答
  •  一生所求
    2020-12-13 02:32

    You can override what the actionbar up button should do like:

    public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    
    case android.R.id.home:
        onBackPressed();
        return true;
    }
    
    return super.onOptionsItemSelected(item);
    }
    

    And recreate the back button effect.

提交回复
热议问题