title: How to open options menu, change setting, and return - Android?
body: <p>I am attempting to get my app to open a settings menu screen and return. The problem I am having is when in the settings page, upon pressing the back button, the app closes. I am VERY new to programming in general after fighting this for about 8 hours I am ready to ask for help! </p>
  
  <p>Here is the code I have written</p>
  
  <p>`package com.bowersoftware.connecttozcu;</p>
  
  <p>import android.app.Activity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuInflater;
  import android.view.MenuItem;
  import android.widget.ArrayAdapter;
  import android.widget.Spinner;
  import android.widget.Toast;</p>
  
  <p>public class ConnecttoZCU extends Activity {</p>
  
  <pre><code>private Spinner mEngineSpinner;
  private Spinner mUnitsSpinner;
  
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      mEngineSpinner = (Spinner) findViewById(R.id.engineSpinner);
      ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource(
              this, R.array.engine, android.R.layout.simple_spinner_item);
      adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      mEngineSpinner.setAdapter(adapter);
  
  }
  
  private void ConnectSettings() {
      setContentView(R.layout.settings);
      mUnitsSpinner = (Spinner) findViewById(R.id.unitsSpinner);
      ArrayAdapter&lt;CharSequence&gt; settingsadapter = ArrayAdapter.createFromResource(
              this, R.array.units, android.R.layout.simple_spinner_item);
      settingsadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      mUnitsSpinner.setAdapter(settingsadapter);
  
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      MenuInflater inflater = getMenuInflater();
      inflater.inflate(R.menu.option_menu, menu);
      return true;
  }
  
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle item selection
      switch (item.getItemId()) {
      case R.id.scan:
          Toast.makeText(this, "Scan", Toast.LENGTH_LONG).show();
          return true;
      case R.id.settings:
          Toast.makeText(this, "Settings", Toast.LENGTH_LONG).show();
          ConnectSettings();
          return true;
      default:
          return super.onOptionsItemSelected(item);
      }
  }
  </code></pre>
  
  <p>}`</p>
  
  <p>I am sure it is something silly I am missing but just can't figure it out. </p>
  
  <p>Thanks, Jason</p>