Toolbar_ActionBar

常英毅
2023-12-01

Toolbar 添加返回键

 Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        getSupportActionBar().setDisplayHomeAsUpEnabled( true);
        getSupportActionBar().setHomeButtonEnabled( true);

 @Override
    public boolean onOptionsItemSelected(MenuItem item) {
           /*when click the app icon change the drawer state*/
        if(item.getItemId() == android.R.id.home){
            finish();
            return true ;
        }
        return super .onOptionsItemSelected(item);
    }


 类似资料:

相关阅读

相关文章

相关问答