content: package com.pxs.terminal;
  
  import android.os.Bundle;
  import android.view.MenuItem;
  
  import androidx.appcompat.app.ActionBar;
  import androidx.appcompat.app.AppCompatActivity;
  import androidx.preference.PreferenceFragmentCompat;
  
  public class SettingsActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.settings_activity);
          if (savedInstanceState == null) {
              getSupportFragmentManager()
                      .beginTransaction()
                      .replace(R.id.settings, new SettingsFragment())
                      .commit();
          }
          ActionBar actionBar = getSupportActionBar();
          if (actionBar != null) {
              actionBar.setDisplayHomeAsUpEnabled(true);
              actionBar.setHomeButtonEnabled(true);
          }
      }
  
      public static class SettingsFragment extends PreferenceFragmentCompat {
          @Override
          public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
              setPreferencesFromResource(R.xml.root_preferences, rootKey);
          }
      }
  
      public boolean onOptionsItemSelected(MenuItem item)
      {
          // TODO Auto-generated method stub
          //android.R.id.home对应应用程序图标的id
          if(item.getItemId() == android.R.id.home)
          {
              finish();
              return true;
          }
          return super.onOptionsItemSelected(item);
      }
  }