Toolbar_ActionBar

来源:互联网 发布:51单片机引脚 编辑:程序博客网 时间:2024/05/16 07:32

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);    }


0 0
原创粉丝点击