How do I close/cancel/dismiss a spinner after I select an item?
<p>When I select an option It opens an activity but when i finish with that activity and I returnt ot the spinner activity, the spinner is still open.</p>

<p>How can I dismiss it right after I select an item?</p>

<pre><code>sp.setOnItemSelectedListener(new OnItemSelectedListener() {
            boolean firstPop =true;
            @Override
            public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1,
                    int pos, long arg3) {
                if (!firstPop) {

                    doMyLogic();
                    sp.????
                }
                firstPop = false;

            }
</code></pre>

<p><strong>edit</strong> full code</p>

<pre><code>public void showDropDownDialogue() {

        String[] s = getResources().getStringArray(R.array.cities);
        final ArrayAdapter&lt;String&gt; adp = new ArrayAdapter&lt;String&gt;(
                MainActivity.this, android.R.layout.simple_spinner_item, s);

        final Spinner sp = new Spinner(MainActivity.this);
        sp.setPadding(5, 5, 5, 5);
        sp.setLayoutParams(new LinearLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        sp.setAdapter(adp);


        sp.setOnItemSelectedListener(new OnItemSelectedListener() {
            boolean firstPop =true;

            @Override
            public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1,
                    int pos, long arg3) {
                if (!firstPop) {
                    editor.putInt("city_id", pos);
                    editor.commit();
                    Intent stationsIntent = new Intent(MainActivity.this,
                    StationsActivity.class);
                    startActivity(stationsIntent);


                }
                firstPop = false;

            }

            @Override
            public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
                // TODO Auto-generated method stub

            }
        });
        AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
        builder.setView(sp);
        builder.create().show();

    }
</code></pre>
