1.设置ToolBar可显示
toolbar.setTitle("");
setSupportActionBar(toolbar);//显示ToolBar
//返回按钮的监听
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
2.重写onOptionsItemSelected方法
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if(item.getItemId()==android.R.id.home){
finish();
}
return super.onOptionsItemSelected(item);
}
网友评论