在java代码中:

添加返回按钮

        Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);

  进行返回

   @Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
finish();// finish your activity
}
return super.onOptionsItemSelected(item);
}

  

05-27 06:20