在java代碼中:java
添加返回按鈕android
Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
進行返回ide
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { finish();// finish your activity } return super.onOptionsItemSelected(item); }