How to call a function at every selection in spinner
<p>I am developing an android application which in I have a class <code>A</code>. The <code>A</code> class have a spinner, and there is a B class which have the spinner's <code>onItemSelected()</code>, <code>B implements OnItemSelectedListener</code> and <code>B</code> is public.
I want to call a function in <code>A</code> when a newer item has selected. So if there selected the <code>first</code> item, and I change it to the <code>second</code> then I want call a function from class <code>A</code>.<br> I always want to call the same <code>A</code>'s function. It's refreshes a list.<br>
<strong>How can I do that?</strong><br>
There's the class <code>A</code>'s spinner which call in <code>A</code>'s <code>onCreate</code>:</p>

<pre><code> public void addListenerOnSpinnerItemSelection() {
    pspinner = (Spinner) findViewById(R.id.spinner1);
    pspinner.setOnItemSelectedListener(new B());
}
</code></pre>

<p>And the B class:</p>

<pre><code>public class B implements OnItemSelectedListener {
    public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int pos, long id){
        Toast.makeText(parent.getContext(),
            "The selected place: " + parent.getItemAtPosition(pos).toString(),
            Toast.LENGTH_SHORT).show();
            A.refresh(); //I think I should call A's function like that but 
                         // Android Studio tells meg that refresh() must be static
    }
}
</code></pre>

<p>Should I call the <code>A</code>'s function in <code>addListenerOnSpinnerItemSelection()</code>? Or in <code>B</code>'s <code>onItemSelected</code>? But how?<br>
Unfortunatelly it's not work that way above. How can I call A's function without make <code>refresh()</code> static?
The spinner gets its elements from an xml.</p>