null pointer exception in spinner adapter
<p>i am trying to use this adapter on spinner , which is giving null pointer exception ,
kindly give ur worthy responses</p>

<pre><code>ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_spinner_item, R.array.select_action_arrays);
</code></pre>

<p>and in my string.xml file</p>

<pre><code>&lt;string-array name="select_action_arrays"&gt;
        &lt;item&gt;alert1&lt;/item&gt;
        &lt;item&gt;alert2&lt;/item&gt;
        &lt;item&gt;alert3&lt;/item&gt;
        &lt;item&gt;alert4&lt;/item&gt;
        &lt;item&gt;alert5&lt;/item&gt;
    &lt;/string-array&gt;
</code></pre>

<p>here is the complete code line</p>

<pre><code>ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.select_action_arrays));
        spinnerSelectAction.setAdapter(adapter);
        spinnerSelectAction = (Spinner)findViewById(R.id.spinnerSelectAction);
        spinnerSelectAction.setAdapter(adapter);
        spinnerSelectAction.setOnItemSelectedListener(new OnItemSelectedListener() {
            int count=0;
            @Override
            public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) {
                if(count &gt;= 1){
                Toast.makeText(getBaseContext(),"inside on item selected ",Toast.LENGTH_SHORT).show();
                }
                count++;
            }
            @Override
            public void onNothingSelected(AdapterView&lt;?&gt; arg0) {}
        });
</code></pre>

<p>the spinnerSelectAction seems to be initialised</p>
