Access Spinner in Activity without define in Layout
<pre><code>Spinner spinner = new Spinner(this);
String option[]={"By Date","By Transaction ID","By Customer Phone"};
ArrayAdapter&lt;String&gt; spinnerArrayAdapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item,option);
spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item );
spinner.setAdapter(spinnerArrayAdapter);
spinner.performClick();
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

    @Override
    public void onItemSelected(AdapterView&lt;?&gt; parentview, View v,int position, long id)
    {
        Log.d("in select","yes");
    }

    @Override
    public void onNothingSelected(AdapterView&lt;?&gt; arg0) 
    {
        Toast.makeText(MainMenu.this,"no",Toast.LENGTH_LONG).show();
        Log.d("In No select","No");
    }
});
</code></pre>

<p>This all are done very fine, a new pop up display of Spinner view is generate on the previous view and previous view still display but dim, all focus on this current Spinner</p>

<p>But the problem is when I select any item in this spinner then onItemSelected() should be called but it is not called.</p>

<p>but if I write</p>

<p><code>setContentView(spinner);</code> </p>

<p>then onItemSelected() is called, but then previous view is not displayed now.</p>

<p>so how can i access spinner without this line <code>setContentView(spinner);</code></p>

<p>I want to get the position of the selected Item in Spinner</p>

<p>Please provide me code or example</p>

<p>i am waiting for your kind reply</p>
