Using support action bar home enabled

后端 未结 5 2259
花落未央
花落未央 2021-02-08 13:31

I\'ve just modified our code to use the new SupportActionBar provided in the v7-appcompat library but when running the code on a Jellybean phone (presumably the same problem exi

5条回答
  •  無奈伤痛
    2021-02-08 13:43

    This one worked for me:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_your_activity);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        // ... other stuff
    }
    
    @Override
    public boolean onSupportNavigateUp(){
        finish();
        // or call onBackPressed()
        return true;
    }
    

    The method onSupportNavigateUp() is called when you use the back button in the SupportActionBar.

提交回复
热议问题