title: Android - How to get the selected item value from a spinner and put it into a string?
body: <p>i read many similar questions on this thread, but none of them help me...
  This is my code:</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      Spinner spinner = (Spinner) findViewById(R.id.imc_spinner);
      // Create an ArrayAdapter using the string array and a default spinner layout
      ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource(this,
      R.array.imc_array, android.R.layout.simple_spinner_item);
      // Specify the layout to use when the list of choices appears
      adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      // Apply the adapter to the spinner
      spinner.setAdapter(adapter);
  
  }
  
  public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int pos, long id) {
      // An item was selected. You can retrieve the selected item using
  
      imc_met = parent.getItemAtPosition(pos).toString();
  
  }
  </code></pre>
  
  <p>I declare imc_met as <code>public String imc_met;</code>. The problem is that imc_met does not contain the value of the selected item of the spinner, but it's null... </p>
  
  <p>Where's the problem?</p>
  
  <p>Thx in advance.</p>