spinner If Strings** == not working
<p>Why is this not working ?!</p>

<pre><code>if(itemx == "Test number item 0")
    {
    Log.i("Dropdown", "inside if");
    us_lo_ans_hold.setText("0x");
    }; 
</code></pre>

<p>if itemx is a String and it has the string 'Test number item 0'.</p>

<p>I am creating my first spinner.</p>

<p>Here is the spinner code within the onCreate block of the Activity:</p>

<pre><code>    Spinner us_lo_spinner = (Spinner) findViewById(R.id.ul_ans_spinner); 
    ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource( this, R.array.test_defaults , android.R.layout.simple_spinner_item); 
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    us_lo_spinner.setAdapter(adapter); 

 // Spinner click listener 
us_lo_spinner.setOnItemSelectedListener(this);
</code></pre>

<p>Here is the String array in the strings.xml:</p>

<pre><code>&lt;string name="spin_title_ulover_ans"&gt;Spinner default:&lt;/string&gt; 
&lt;string-array name="test_defaults"&gt; 
    &lt;item&gt;Test number item 0&lt;/item&gt;
    &lt;item&gt;Test number item 1&lt;/item&gt; 
    &lt;item&gt;Test number item 2&lt;/item&gt; 
    &lt;item&gt;Test number item 3&lt;/item&gt; 
    &lt;item&gt;Test number item 4&lt;/item&gt; 
&lt;/string-array&gt;
</code></pre>

<p>Here is the onItemSelected:</p>

<pre><code>public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) 
{
    Log.i("XXX_Dropdown", "XXXX");
    TextView us_lo_ans_hold = (TextView)findViewById(R.id.us_lo_ans_holdtest);
    // On selecting a spinner item 
    String itemx = arg0.getSelectedItem().toString();
    us_lo_ans_hold.setText("oppp12");
    Log.i("Dropdown", "item: " + itemx);
    Log.i("Dropdown", "arg1: " + arg1);
    Log.i("Dropdown", "arg2: " + arg2);
    Log.i("Dropdown", "arg3: " + arg3);
    // Showing selected spinner item 
    if(itemx == "Test number item 0")
        {
        Log.i("Dropdown", "inside if");
        us_lo_ans_hold.setText("0x");
        }; 

}
</code></pre>

<p>From all the Log.i(,)s I put in I can tell the itemx is correct, it has the correct string when an item in the spinner is selected.
Yet the IF will not work.</p>

<p>If I change the IF to this:</p>

<pre><code>if(arg2 == 0)
    {
    Log.i("Dropdown", "inside if");
    us_lo_ans_hold.setText("0x");
    }; 
</code></pre>

<p>it will work; BUT that is not what I want!</p>

<p>So... why is this not working ?!:</p>

<pre><code>if(itemx == "Test number item 0")
    {
    Log.i("Dropdown", "inside if");
    us_lo_ans_hold.setText("0x");
    }; 
</code></pre>

<p>if itemx is a String and it has the string 'Test number item 0'. ?</p>

<hr>

<p>also how or when would 'onNothingSelected' be called?
When you hit the back button ?
When you select the item already selected?
My 'onNothingSelected' is never called !</p>

<pre><code>public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
    // TODO Auto-generated method stub
    Log.i("Dropdown", "in NOTHING SELECTED");
    TextView us_lo_ans_hold = (TextView)findViewById(R.id.us_lo_ans_holdtest);
    us_lo_ans_hold.setText("nothing selected");
}
</code></pre>

<p>Tried putting in the onCreate block of the Activity like the:</p>

<pre><code>    // Spinner click listener 
    us_lo_spinner.setOnItemSelectedListener(this);

us_lo_spinner.onNothingSelected(this)   
</code></pre>

<p>but the ~compiler~ does like that.</p>

<p>So... how or when is 'onNothingSelected' called and how is it hooked up to a spinner ?</p>
